TestsTested | ✓ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Apr 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✗ |
Maintained by Tim Bodeit.
Image spacing and side selection for UIButton. Fully auto-layout compatible.
Setting text and image on TextImageButton works like it does on a vanilla UIButton:
let button = TextImageButton()
button.setTitle("I'm a TextImageButton", forState: .Normal)
button.setImage(UIImage(named: "beachball"), forState: .Normal)
It allows specifying the spacing between title and image:
button.spacing = 20
To choose the side the image is set on, specify imagePosition
.
There is also boolean @IBInspectable imageOnRight
attribute that you can set inside the storyboard
button.imagePosition = .Right
While TextImageButton can be used in Objective-C code, it is written completely in Swift.
Version 0.2 is compatible with Swift 3. For Swift 2 use Version 0.1.1.
To run the example project, clone the repo, and run pod install
from the Example directory first.
TextImageButton is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod TextImageButtonpl-pds>
Tim Bodeit, [email protected]
Inspired by this stackoverflow answer by jasongregori.
TextImageButton is available under the MIT license. See the LICENSE file for more info.