GithubHelp home page GithubHelp logo

loregr / lgbutton Goto Github PK

View Code? Open in Web Editor NEW
2.3K 38.0 140.0 1.32 MB

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

License: MIT License

Swift 80.26% Ruby 0.17% Objective-C 0.11% C 0.21% Python 19.25%
uicontrol uibutton swift ios font-icons interface-builder beautiful-buttons xcode ios-swift swift-4

lgbutton's Introduction

cover image

Linkedin Badge Website Badge Medium Badge

๐Ÿ’ก About Me

Professional Software Engineer with a passion for mobile technology. Experienced designer, trainer, and team lead with a focus on best practices and excellence.

  • I speak: ๐Ÿ‡ฎ๐Ÿ‡น ๐Ÿ‡ฌ๐Ÿ‡ง
  • My passions: ๐Ÿ‹๐Ÿปโ€โ™‚๏ธ ๐ŸŽต ๐Ÿ›ซ ๐Ÿ“ฑ ๐Ÿ’ป

๐Ÿ“ฑ Mobile Experience

My first approach to mobile development was in 2011 when I built my first Android app in Java. I got so passionate about the mobile world that few months later I developed my first iOS app in Obj-C. Since then, I always wanted to stay updated with the cutting edge technologies, so I studied Swift (2014) and Kotlin (2016). In 2018 I decided to put my focus on Flutter and started to develop apps in Dart, while always keeping an eye to the native mobile development world.

mobile experience

๐ŸŒŸ Some of my apps

lgbutton's People

Contributors

anarchoschnitzel avatar cdoky avatar gumbright avatar loregr avatar manucheri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lgbutton's Issues

Still get black border arounded rounded image

Describe the bug
#33

To Reproduce
Steps to reproduce the behavior:
Round a button fully
add a white border
voila
the circle has a black very thin border

This is the same issue reported in issue 33, was this resolved?

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
}

Please add Carthage support

This is a popular dependency manager, many use it. You have a good library, it is a pity that it does not yet support installation via Carthage.

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

Transparent or non-opaque button backgrounds

Is there a way to make the button background transparent or non-opaque with alpha component less than 1? I pulled an IBOutlet into my VC as a UIView and attempted to set the backgroundColor to dark gray with alpha component 0.25 but that doesn't seem to work. Is it even possible?

Here's my code

@IBOutlet weak var cameraButton: UIView!
cameraButton.isOpaque = false
cameraButton.backgroundColor = UIColor.darkGray.withAlphaComponent(0.25)

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.

rootView added as a subview twice

xibSeup is called twice, first from init then later from awakeFromNib, resulting in the rootView being added twice to the view hierarchy.

WOFF2 support

Have you tried using WOFF2 assets instead of TTF/OTF ? File-size is reduced greatly (asset folder goes from 897KB to 282KB)

There's no real info about official support other than the announcement in Safari's patch notes (WOFF2 works in iOS >= 10). Adding support for WOFF2 (with WOFF fallback for earlier iOS versions) is quite simple since it only required modifying a single line of code

Maybe push it as a new sub-spec ?

addGestureRecognizer don't work

Describe the bug
Aftet update to last version, i can't add gesture recognizer in referenced buttons.

To Reproduce

 override func viewDidLoad() {
///..
 let tap = UITapGestureRecognizer(target: self, action: #selector(self.handleButton))
 self.button.addGestureRecognizer(tap)
 self.button.isUserInteractionEnabled = true
///..
}
 @objc func handleButton() {
        self.dismiss(animated: true, completion: nil)
    }

Expected behavior
I need add touch button action from code because is dynamic.

Smartphone (please complete the following information):

  • Device: All
  • Version Last
  • Swift 5

Support setting NSAttributedString as title

It would be nice if we can also set NSAttributedString as button title. In one of my project, I created all buttons programmatically and wanted to set NSAttributedString for some of them.

pod install not working

Added to pod as

pod 'LGButton'

But keep getting this error upon pod install

[!] Unable to find a specification for 'LGButton'

Swift 3, Xcode 8

Can you have a statically sized button and center the icon and title?

Is it possible to have a statically defined width (or one constrained by autolayout) and have the title and icon/image centered in the middle of the button? Right now, it looks like if I use autolayout or statically define a button size, that the title and icon will be aligned to the button edges.

Updated google plus icon

How do I get the updated google plus icon from font awesome? When I set the corresponding values to fa and google-plus-g, I don't see the updated Google Plus.

Any help would be much appreciated! Thanks!

pod install version 1.1.2

Add here your question
just find out there is version 1.1.5 to fix some touch bugs. which are present in my project
how can i update to 1.1.5

border looks not good!

I want the border color is white, and the superview background is white too. It looks not good! How to solve this issue?
screen shot 2018-06-14 at 6 37 08 pm

Long compile times

Describe the bug
Is anyone else experiencing really long archive times for LGBUtton? I'm using v1.1.6 of the library, and this issue exists with v1.1.5 as well. I thought upgrading Xcode from 10.2 to 10.2.1 would fix it, as I assumed it was a bug with the Swift compiler, but the issue persists.

This only happens during the archive phase, with device set to "Generic iOS Device". And does not happen when simply building for a device

To Reproduce
Steps to reproduce the behavior:

  1. Create a new iOS UIKit project
  2. Create a Podfile with LGButton (you can use the sample I pasted below, as that's what I used to test)
  3. Run Pod update/install to get the latest version
  4. Open workspace, set device to "Generic iOS Device" and hit the archive button
  5. Watch that the compiler is stuck compiling LGButton

Expected behavior
Archive should not take long to archive the LGButton library. This is not a project or app specific issue, as I experienced this in a brand new project.

Desktop (please complete the following information):

  • OS: macOS 10.4.4

Smartphone (please complete the following information):

  • Device: Generic iOS Device
  • Xcode: 10.2 and 10.2.1

Additional context
Add any other context about the problem here.

platform :ios, '12.0'
use_frameworks!
# ignore all warnings from all pods
inhibit_all_warnings!

target 'Testing' do

pod 'LGButton'

end

Modify disabled colour

Can you make it so that we can define what the button will look like when its disabled?
Right now the enabled and disabled button look extremely simular.

Tap gesture conflict

I use an IBAction with event "Touched up inside" and my view controller has also a UITapGestureRecognizer. When I touch my button the IBAction is not called because the tap gesture prevail. That is not the case with a UIButton.
I found that some UIControl functions setting the Hilighted property are override in the LGButton class and that is not the case in UIButton class.

The solution I used is to use my view controller as a delegate of my gesture recognizer and to check if the location of the tap is inside my button bounds.

Preview dissapears from Storyboard

Hi, i was designing a view in the story board when I opened again XCode all the Buttons, are not visible. They are still there, but I canยดt view then in the Storyboard.

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'

Centered Vertical Button

Is it possible to configure centered vertical button?
When I set it up the image goes to the top and the text goes to the bottom.

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

Error

A lot of errors in pod files. SwiftIconFont.Swift and Fontloader.swift have some error

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

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

AutoLayout errors show up

A lot of AutoLayout errors show up after adding LGButton to a view hierarchy which had no AutoLayout errors or warnings before, and even in a setup with only one single button as unique subview

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 3dfd991), the problem will no longer exists.

change button title

thanks for your pod.
I use it in my app but when I want change button title by this code:
buyBtn.titleString = "play"

buyBtn is outlet from lgButton that I use in my view controller
but app crash with this error :
Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value

Update for Swift 4.2 in pod

Hello,
I was just going to send a pull request for updating to swift 4.2 but i noticed the source code is on swift 4.2 only the update hasn't been delivered to cocoapods. So if you could, please bump your version with new changes you have already made.

Thanks in advance

Vertical alignment for image and title

Nice UIControl !!

Just missing Vertical alignment for image and title. Like this.
screen shot 2017-06-20 at 8 29 25 am

I know It can be fix using titleEdgeInsets & imageEdgeInsets, but it would be great if control have this functionality too.

Thanks.

adjustFontToFitWidth

Is there anyway to force the title label to use adjustFontToFitWidth if it doesn't fit in the space? Would like the icon(s) to take priority, then the font size decreases based on how much space is left for the text label

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.