A fully customisable subclass of the native UIControl which allows you to create beautiful buttons without writing any line of code.

Overview

logo

build platform license Version

A fully customisable subclass of the native UIControl which allows you to create beautiful buttons without writing any line of code.

Preview

You'll be able to create buttons like these by using only the interface builder:

preview

Moreover you can use them for asynchronous operations.

async

Install

To integrate LGButton into your Xcode project using CocoaPods, specify it in your Podfile:

use_frameworks!

pod 'LGButton'

Icons and images

You can add images/icons to your button, icons are taken from different ready to use font icons collections, images can be imported directly from your project assets folder.

You can customise icons/images on the left and/or on the right of the button title.

Icons

Icons are managed by SwiftIconFont integration, so you can easily add and customise button icons by choosing from the most popular font icons collections. In particular:

Collection Font name Cheat Sheet
Font Awesome fa List
Ion Icons io List
Octicons oc List
Open Iconic ic List
Material Icon ma List
Themify ti List
Map Icons mi List

The main properties that you need to set in order to use font icons are:

  • Icon Font Name: you can pick one value from the table above, different values will be ignored (please consider that not all the icons may be available since this library may not be updated right after a font library update).

  • Icon String: the icon name taken from the cheatsheet without the collection prefix.

So, if you want to use fa-align-left from Font Awesome, Icon Font Name will be fa and Icon String will be align-left.

Images

Set the Image source property in order to use an image from your assets folder.

Note: if Image source is set, every other property about the font icon on the same side will be ignored.

Usage

Drag and drop an UIView object into your view controller and set its class and module to LGButton.

class

Customise your button by setting the properties from the Interface Builder.

properties_1 properties_2

Supported Attributes

Attribute Description Default value
Bg Color Main background color clear
Show Touch Feedback Whether a touch feedback should be visible or not true
Gradient Start Color The first color of the gradient background nil
Gradient End Color The second color of the gradient background nil
Gradient End Color The second color of the gradient background nil
Gradient Horizontal Whether the gradient should be horizontal or not false
Gradient Rotation Set the gradient rotation angle (degrees from -360 to 360) 0
Corner Radius The corner radius 0.0
Fully Rounded Corners Apply a corner radius equals to height/2 false
Border Color The border color white
Border Width The border width 0.0
Title Color The title color white
Title String The title string EMPTY_STRING
Title Font Name The title font name nil
Title Font Size The title font size 14.0
Vertical orientation If true the left icon will be placed on the top and the right icon will be placed on the bottom false
Left Icon String The name of the left icon (taken from the cheat sheet) EMPTY_STRING
Left Icon Font Name The name of the left icon font name (taken from the table above) EMPTY_STRING
Left Icon Font Size The left icon font size 14.0
Left Icon Color The left icon color white
Left Image Src The name of the left source asset nil
Left Image Height The left image height 20.0
Left Image Width The left image width 20.0
Left Image Color The left image tint color nil
Right Icon String The name of the right icon (taken from the cheat sheet) EMPTY_STRING
Right Icon Font Name The name of the right icon font name (taken from the table above) EMPTY_STRING
Right Icon Font Size The right icon font size 14.0
Right Icon Color The right icon color white
Right Image Src The name of the right source asset nil
Right Image Height The right image height 20.0
Right Image Width The right image width 20.0
Right Image Color The right image tint color nil
Spacing Title Icon The spacing between the title and the image/icon 16.0
Spacing Top The internal top spacing 8.0
Spacing Bottom The internal bottom spacing 8.0
Spacing Leading The internal leading spacing 16.0
Spacing Trailing The internal trailing spacing 16.0
Shadow Offset The shadow offset (0,0)
Shadow Radius The shadow radius 0.0
Shadow Opacity The shadow opacity 1.0
Shadow Color The shadow color black
Loading spinner Color The loading spinner color white
Loading String The loading message text EMPTY_STRING
Loading Font Name The loading message font name EMPTY_STRING
Loading Font Size The loading message font size 14.0
Left Aligned true if the button items should be aligned to the left. It requires the button to have a fixed width false
Right Aligned true if the button items should be aligned to the right. It requires the button to have a fixed width false

You can download the demo project if you want to check more.

Issues

Feel free to submit issues and features requests.

Contributing

Contributions are more then welcome. Your contribution may include bug fixing or/and new features.

Please follow the "fork-and-pull" Git workflow (check here for more).

  1. Fork the repo on GitHub
  2. Clone the project to your own machine
  3. Commit changes to your own branch
  4. Push your work back up to your fork
  5. Submit a Pull request so that I can review your changes

NOTE: Be sure to merge the latest from "upstream" before making a pull request!

Author

Lorenzo Greco

Credits

SwiftIconFont project is used in order to provide ready to use icons.

License

MIT License

Copyright (c) 2017 Lorenzo Greco

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Comments
  • Bug on tap action

    Bug on tap action

    After updating from 1.0.5 to 1.1.1, I need to hold the button to receive the IBAction in my view controller instead of just tap the button. I tested some things and found that if you remove the "if" of line 708 of file "LGButton.swift" (based on commit 3dfd991b3c823465b44a7e22fe914694382d0303), the problem will no longer exists.

    bug 
    opened by Josuepdc 19
  • Xcode 9.3 rendering error

    Xcode 9.3 rendering error

    Since Xcode 9.3 I get rendering errors with LGButton and that even makes most of my views invisible in Storyboard! Here is the error:

    error: IB Designables: Failed to render and update auto layout status: dlopen(LGButton.framework, 1): no suitable image found.  Did find:
    	LGButton.framework: required code signature missing for 'LGButton.framework'
    
    opened by arytbk 8
  • Button appears grey by default and when the view is charging

    Button appears grey by default and when the view is charging

    The default background color should be clear but it's between dark grey and light grey for me. Plus, when the view is charging at beginning we can see it grey instead of the chosen color (I'm using Storyboard).

    opened by OxyFlax 6
  • LGButton's gradients or background color does not change

    LGButton's gradients or background color does not change

    Describe the bug Depending on a flag, I want to change the gradient colors (Or, background color) of an LGButton. But, we cannot change the colors runtime from whatever the colors the button is initially initiated with or given on storyboard.

    To Reproduce Steps to reproduce the behavior:

    1. Drag an UIView onto any UIViewController's UIView or another UIView.
    2. Make it an instance of LGButton and assign an IBOutlet
    3. Assign them two gradient colors or just background color.
    4. Have a piece of code something like shown below to have new gradient colors.
    5. Check if new gradients are applied to the lgButton.
    if status == true {
        lgButton.gradientStartColor = .red
        lgButton.gradientEndColor = .green
    } else {
        lgButton.gradientStartColor = .gray
        lgButton.gradientEndColor = .white
    }
    
    

    Smartphone (please complete the following information): iOS 12, 11

    bug stale 
    opened by idevChandra6 4
  • Make LGButton open, so subclassable ?

    Make LGButton open, so subclassable ?

    For example, we need to patch some handy instance functions for the button, I would naturally think we can subclass it, then we can use the shared handy function everywhere, and make UI configs consistent

    sth like:

    clsss CustomButton: LGButton {
         init(withButtonTitle){
             super.init()
              // custom config
              // ....
         }
        
          func enableButton() {
              self.isEabled = true
              // other custom UI change to enabled button
              // ...
           }
           func disableButton() {
              // counterpart to enableButton.
            }
            
             //.. other functions needed per custom requirements
    }
    
    question 
    opened by 10000TB 4
  • - Delete .py from resources

    - Delete .py from resources

    [18:55:52]: [Transporter Error Output]: ERROR ITMS-90035: "Invalid Signature. Code object is not signed at all. The file at path [iOS.app/Frameworks/LGButton.framework/GetTTFFontName.py] is not properly signed. Make sure you have signed your application with a distribution certificate, not an ad hoc certificate or a development certificate. Verify that the code signing settings in Xcode are correct at the target level (which override any values at the project level). Additionally, make sure the bundle you are uploading was built using a Release target in Xcode, not a Simulator target. If you are certain your code signing settings are correct, choose "Clean All" in Xcode, delete the "build" directory in the Finder, and rebuild your release target. For more information, please consult https://developer.apple.com/library/ios/documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html"

    opened by cdoky 4
  • Carthage support

    Carthage support

    In addition to CocoaPods I think Carthage support would be nice to have.

    I might have time to help implement this in the future, but submitting an issue now in case someone feels up to the task.

    Carthage info: https://github.com/Carthage/Carthage

    I think the only thing that needs to be changed is making the schemes for building the framework 'shared'.

    Releases are already tagged according to SemVer, which Carthage will respect automatically, so that is already done.

    enhancement stale 
    opened by manucheri 4
  • Left Align Content

    Left Align Content

    I was just wondering how to left align the content of the button, I can not get it working. This is the code I am using, with auto layout constaints to fill the button to a set width.

        let test: LGButton = {
            let lg = LGButton()
            lg.leftIconFontName = "io"
            lg.leftIconColor = UIColor.brandWhite
            lg.leftIconString = "social-youtube"
            lg.titleFontName = "AvenirNext-Bold"
            lg.leftIconFontSize = 18
            lg.titleFontSize = 18
            lg.cornerRadius = 16
            lg.titleString = "Show video"
            return lg
        }()
    

    As you can see in the image below, the title is right aligning and if I set the spacingLeading or the spacingTrailing the all the content just centres when I would like it to be left aligned.

    Imgur I am aiming for it to look like this (Have not set the right font sizes or colours yet): Imgur

    enhancement 
    opened by kevinmann 4
  • Spacing title icon doesn't work

    Spacing title icon doesn't work

    When I put a left icon (string:camera, font: io) and a title string, they are both at the opposite of the UIView. Icon is at the extreme left and text at the extreme right. Setting "Spacing title icon" doesn't allow me to bring them closer, only "Spacing leading" and "Spacing trailing" change something.

    PS: My LGButton is in a stackview with trailing constraints.

    capture d ecran 2017-08-15 a 14 42 43
    opened by OxyFlax 4
  • Storyboard

    Storyboard

    Is anyone else getting issue where if LGButton is added to their storyboard, Xcode will show internal error has occurred and will not load the storyboard at all?

    bug stale 
    opened by roarapps 3
  • Add IBAction for Button

    Add IBAction for Button

    I create LGButton IBAction method, But not performing any action which, if your hold that button form a minute then it perform IBAction function. It happen in one touch like normal button

    opened by AbhishekJ17 3
Releases(1.1.6)
Owner
Lorenzo Greco
Software engineer with a background and passion for mobile technology.
Lorenzo Greco
An easy way to create beautiful social authentication buttons

EasySocialButton An easy way to create beautiful social authentication buttons Screenshots Installation Cocoa Pods pod 'EasySocialButton' Manual Drag

Antonio Zaitoun 162 Dec 11, 2022
Lickable-Button We made the buttons on the screen look so good you'll want to lick them

Lickable-Button We made the buttons on the screen look so good you'll want to lick them. - Steve Jobs A little SwiftUI button project at WWDC 2021 Lic

Nate Thompson 14 Dec 29, 2021
An open-source library to use with SwiftUI, It allows you to create Floating menu action button.

Floating Menu Action Button Example Overview This is an open-source library to use with SwiftUI. It allows you to create Floating menu action button. Ins

ugo 3 Aug 19, 2022
RadioGroup - The missing iOS radio buttons group.

RadioGroup The missing iOS radio buttons group. Usage let radioGroup = RadioGroup(titles: ["First Option Title", "Another Option Title", "Last"]) radi

Yonat Sharon 188 Dec 20, 2022
Animated Social share buttons control for iOS written in Swift

SwiftShareBubbles Animated Social share buttons control for iOS written in Swift. This library is inspired AAShareBubbles. I tried AAShareBubbles with

Takeshi Fujiki 175 Jun 11, 2022
Added functionality that system buttons are not easy to implement

LLCustomButton Added functionality that system buttons are not easy to implement What are the functions ? Sets the position and spacing of text and im

coder 18 Jul 28, 2022
Added functionality that system buttons are not easy to implement

LLCustomButton Added functionality that system buttons are not easy to implement What are the functions ? Sets the position and spacing of text and im

coder 18 Jul 28, 2022
Inspired by Apple’s download progress buttons in the app store

GBKUIButtonProgressView Inspired by Apple’s download progress buttons in the app store Created by @pklada and @miketsprague Checkout the blog post. In

Guidebook 541 Sep 1, 2022
Yet another animated flat buttons in Swift

DynamicButton is a powerful flat design button written in Swift to display hamburger button like with animated transitions between style updates. It a

Yannick Loriot 1.2k Jan 5, 2023
LabelButtonKit is a mini library for labeled buttons (of SF Symbols), written entirely in SwiftUI

A simple Button with an SFSymbol (icon) as a label, vertically. As well as a Dynamic Type variant using it horizontally. Using SwiftUI. A List View of buttons is also available here. Have fun! ??

Marcos Morais 5 Nov 26, 2022
A small and flexible (well documented) UIButton subclass with animated loading progress, and completion animation.

ButtonProgressBar-iOS Example For LIVE PREVIEW on Appetize in your browser itself, click here. To run the example project, clone the repo, and run pod

Pushkar Sharma 566 Dec 9, 2022
Interactive and fully animated Material Design button for iOS developers.

WYMaterialButton Inspired by Google Material Design, written purely in Swift 3. WYMaterialButton implemented Material Design on iOS and add more dynam

Yu Wang 76 Oct 7, 2022
TTopImageBottomLabelButton is a simple and flexible UI component fully written in Swift

TTopImageBottomLabelButton is a simple and flexible UI component fully written in Swift. TTopImageBottomLabelButton is developed to help programmers create a button with top image and bottom title quickly without having to write many lines of codes.

Nguyen Duc Thinh 2 Aug 18, 2022
Jorge Ovalle 305 Oct 11, 2022
A fully customisable swift subclass on UIButton which allows you to create beautiful buttons without writing any line of code.

JSButton Demo $ pod try JSButton ...or clone this repo and build and run/test the JSButton project in Xcode to see JSButton in action. If you don't ha

Jogendra 12 May 9, 2022
A UIControl subclass that makes it easy to create empty states.

AZEmptyState Making empty state simple. Screenshots Installation Cocoa Pods: pod 'AZEmptyState' Manual: Simply drag and drop the Sources folder to you

Antonio Zaitoun 88 Oct 2, 2022
SMNumberWheel is a subclass of UIControl written in Swift, which is ideal for picking numbers using a rotating wheel.

SMNumberWheel version: 1.0.3 [![CI Status](http://img.shields.io/travis/Sina Moetakef/SMNumberWheel.svg?style=flat)](https://travis-ci.org/Sina Moetak

null 26 Mar 15, 2022
An auto-layout base UITextView subclass which automatically grows with user input and can be constrained by maximal and minimal height - all without a single line of code

Deprecated This library is no longer maintained and is deprecated. The repository might be removed at any point in the future. MBAutoGrowingTextView A

Matej Balantič 125 Jan 13, 2022
slider view for choosing categories. add any UIView type as category item view. Fully customisable

CategorySliderView Horizontal or vertical slider view for choosing categories. Add any UIView type as category item view. Fully customisable Demo Inst

Cem Olcay 353 Nov 6, 2022
Primer iOS SDK - Instantly deploy native screens without writing code

Instantly deploy native screens without writing code. Primer enables you to design and test new user experiences, and personalize them for each user.

Primer 6 Mar 23, 2018