All Projects → TakeScoop → Swiftybutton

TakeScoop / Swiftybutton

Licence: mit
Simple and customizable button in Swift

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Swiftybutton

Selector-Closure
A light way to convert objc target-action style to closure
Stars: ✭ 14 (-97.03%)
Mutual labels:  uikit, uibutton
Flutter Ui Kits
Free Flutter UI Kits developed by Olayemi Garuba
Stars: ✭ 484 (+2.76%)
Mutual labels:  mobile, uikit
Dtgradientbutton
Easy way to set gradient background to your buttons.
Stars: ✭ 76 (-83.86%)
Mutual labels:  uikit, uibutton
Fluttersocialappuikit
Flutter representation of a Social App Concept.
Stars: ✭ 1,270 (+169.64%)
Mutual labels:  mobile, uikit
RCPickerButton
Simple button for marking some items as selected.
Stars: ✭ 17 (-96.39%)
Mutual labels:  uikit, uibutton
Components
MobileUI was created thinking of making your hybrid application faster and smaller since you only install what you are really going to use for UI.
Stars: ✭ 125 (-73.46%)
Mutual labels:  mobile, uikit
H5ui
Lightweight, elegant open source mobile UI style library.
Stars: ✭ 44 (-90.66%)
Mutual labels:  mobile, uikit
ALRadioButtons
RadioButtons for iOS. Inherited from UIControl, support 2 native styles, fully customizable.
Stars: ✭ 65 (-86.2%)
Mutual labels:  uikit, uibutton
Fluttergrocery Shoppingappui
🍔😋 Grocery Shopping App template UI kit in Flutter
Stars: ✭ 388 (-17.62%)
Mutual labels:  mobile, uikit
Mdb Ui Kit
Bootstrap 5 & Material Design 2.0 UI KIT
Stars: ✭ 21,830 (+4534.82%)
Mutual labels:  uikit
Hexo Theme Yilia Plus
一个简洁优雅的hexo主题 A simple and elegant theme for hexo.
Stars: ✭ 462 (-1.91%)
Mutual labels:  mobile
React Phone Input 2
📞 Highly customizable phone input component with auto formatting
Stars: ✭ 446 (-5.31%)
Mutual labels:  mobile
React Native App Link
Easily link to other apps with React Native.
Stars: ✭ 449 (-4.67%)
Mutual labels:  mobile
Cp Design
A configurable Mobile UI Components(React hooks+Typescript+Scss)组件库
Stars: ✭ 465 (-1.27%)
Mutual labels:  mobile
Awesome Test Automation
A curated list of awesome test automation frameworks, tools, libraries, and software for different programming languages. Sponsored by http://sdclabs.com
Stars: ✭ 4,712 (+900.42%)
Mutual labels:  mobile
Stayaway App
Official repository for the STAYAWAY COVID mobile application
Stars: ✭ 468 (-0.64%)
Mutual labels:  mobile
Fluttermates
A quick sample app on how to implement a friend list and a profile page in Flutter.
Stars: ✭ 444 (-5.73%)
Mutual labels:  mobile
Docs
Documentation, API reference, and code snippets for NativeScript
Stars: ✭ 442 (-6.16%)
Mutual labels:  mobile
Mtcnn ncnn
基于ncnn框架搭建win及android端的MTCNN人脸检测工程
Stars: ✭ 471 (+0%)
Mutual labels:  mobile
Lgame
A cross-platform Java game Engine (Framework) , support JavaFX / Android / IOS / HTML5 / Linux / MAC / Windows
Stars: ✭ 467 (-0.85%)
Mutual labels:  mobile

SwiftyButton

Maintainer(s): @nickm01 @pmacro @aryamansharda

Simple and customizable button in Swift.

Carthage compatible

Installation

Cocoapods

pod 'SwiftyButton'

Carthage

github 'TakeScoop/SwiftyButton'

Usage

Flat Button

let button = FlatButton()
button.color = .cyan
button.highlightedColor = .blue
button.cornerRadius  = 5

Pressable Button

let button = PressableButton()
button.colors = .init(button: .cyan, shadow: .blue)
button.shadowHeight = 5
button.cornerRadius = 5

All Properties

Here is a list of all the properties that you can modify. Those are all editable directly from Interface Builder. See FlatButton.Defaults or PressableButton.Defaults to set defaults for those properties.

FlatButton

button.color = .cyan
button.highlightedColor = .cyan
button.selectedColor = .blue
button.disabledButtonColor = .gray
button.cornerRadius = 8

PressableButton

button.colors = .init(button: .cyan, shadow: .blue)
button.disabledColors = .init(button: .gray, shadow: .darkGray)
button.shadowHeight = 10
button.cornerRadius = 8
button.depth = 0.5 // In percentage of shadowHeight

Interface Builder (Storyboard/XIB)

Add a UIButton as usual, then:

  • Modify the underlying class to FlatButton/PressableButton, and that the module is set to SwiftyButton
  • Make sure that the button type is set to Custom

Defaults

You can set defaults that will be applied for any new instance of SwiftyButton by modifying the FlatButton.Defaults or PressableButton.Defaults structure:

FlatButton.Defaults.color = .cyan
PressableButton.Defaults.cornerRadius = 8
...

Custom Content

Use CustomPressableButton to add custom content in a Swifty Button.

This is a subclass of SwiftyButton that exposes a content view that moves when the button state changes. All you have to do is add your views inside button.contentView and setup layout constraints relative to this view.

Install

pod `SwiftyButton/CustomContent`

Usage

Here is how you would create a button similar to the one above (here we used PureLayout for constraints):

let button = CustomPressableButton()

let indicator = UIActivityIndicatorView(activityIndicatorStyle: .white)
button.contentView.addSubview(indicator)
indicator.autoPinEdgesToSuperviewEdges(with: UIEdgeInsets(top: 10, left: 15, bottom: 10, right: 0), excludingEdge: .right)
indicator.startAnimating()

let label = UILabel()
button.contentView.addSubview(label)
label.autoPinEdgesToSuperviewEdges(with: UIEdgeInsets(top: 10, left: 0, bottom: 10, right: 10), excludingEdge: .left)
label.autoPinEdge(.left, to: .right, of: indicator, withOffset: 10)
label.text = "Loading..."
label.textColor = .white

Known limitations

  • PressableButton only works with plain colors (no alpha / transparency) because of the way its background image is rendered. See #2
  • PressableButton manages title and image insets automatically (titleEdgeInsets and imageEdgeInsets). See #5
    • User-specified inset values for top and bottom will be overridden.
    • You may specify inset values for left and right.

More examples

Look at the Examples folder to see more button examples.

Contribute

Publishing a new version

Here's an example of a version bump: bump to 0.8.0.

Replace NEW_VERSION with the version you're about to publish.

  • Checkout the master branch and ensure it's up-to-date.
  • Open SwiftyButton.xcworkspace and edit settings for the SwiftyButton target. Change the target version to NEW_VERSION.
  • Open CHANGELOG.md and add a new section [NEW_VERSION]. At the bottom of the document, copy a version anchor and link to the new version tag (which we'll create later). Insert a new empty [master] section on top.
  • Open SwiftyButton.podspec and edit s.version to NEW_VERSION.
  • Commit your changes as Bump to NEW_VERSION.
  • Create a new git tag named NEW_VERSION and push your commit + tag to Github.
  • Push the new pod version with $ pod trunk push ./

License

This project is copyrighted under the MIT license. Complete license can be found here: https://github.com/TakeScoop/SwiftyButton/blob/master/LICENSE

Credits

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].