Menu โ Installation โข Usage โข Features
UIAdvancedButton
is an open-source subclass of UIKit's UIControl implemented as a ready-to-use button, coming with different styles, animations, and parameters. It is designed to be permormant and accessible.
pod 'UIAdvancedButton'
.package(url: "https://github.com/stevensyp/UIAdvancedButton.git")
// 1 - Import the framework
import UIAdvancedButton
// 2 - Instantiate the button through IB or code
let button = UIAdvancedButton()
@IBOutlet weak var button: UIAdvancedButton!
// 3 - Customize the properties
button.title = "Press Me"
button.glyph = UIImage(systemName: "hand.tap.fill")
button.set(colorStyle: .medium, contentLayout: .horizontalReversedSpaced)
button.cornerRadius = 8
// 4 - Define an action when pressed
button.tappedHandler = {
print("Button pressed!")
}
tintColor
)UIAdvancedButton uses only its tintColor
to define its color layout (background and/or text color) depending on the selected colorStyle
. You can still set border color independently. Changing backgroundColor
won't have any effect. Default is systemBlue
.
colorStyle
)Property | Detail | Preview |
---|---|---|
.full |
(Default) Plain background color, and light/dark text. | |
.medium |
Background with reduced opactiy, and colored text. | |
.neutral |
Light/dark background (.systemBackground ), and colored text. |
|
.neutralGray |
Light gray background (.secondarySystemFill ), and colored text. |
|
.system |
Clear background and colored text. |
contentLayout
)Property | Detail | Preview |
---|---|---|
.horizontal |
(Default) Centered text, with the glyph at its left. | |
.horizontalReversed |
Centered text, with the glyph at its right. | |
.horizontalReversedSpaced |
Left-aligned text, with right-aligned glyph. |
isContentBold
)Defines if the content's weight of the button is semibold
or regular
. Default is true
.
isAnimatedWhenPressed
)The button will slightly shrink when pressed. Default is true
.
The button supports two different ways to handle tapping inside its bounds.
button.tappedHandler = { ... }
ยท Closure block.button.addTarget(...)
ยท Good old #selector
.Requirements: Swift 5 ยท Xcode 12 ยท iOS 13
UIAdvancedButton
is available under the MIT license. Please see the LICENSE file for more information.
link |
Stars: 1 |
Last commit: 2 years ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics