Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
Pod
 
 
 
 
 
 
 
 
 
 
 
 

AddButton

CI Status Version License Platform

Description

AddButton is a simple button which has two states. One will display an add sign, the other a checkmark.

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Storyboard

To use AddButton in your own project simply take a UIView object and set its class to AddButton. You can customize various properties directly in Interface Builder like the strokeColor or lineWidth.

In Code

// create an AddButton and add it as a subview
let addButton = AddButton(frame: CGRect(x: 50, y: 50, width: 44, height: 44))
view.addSubview(addButton)

// add target and action
addButton.addTarget(self, action: #selector(addButtonTapped(_:)), forControlEvents: .TouchUpInside)

// change the button state when tapped
@IBAction func addButtonTapped(sender: AddButton) {
  sender.added = !sender.added
}

Customizations

AddButton provides various customizations which can be done either in code or in Interface Builder.

/// Stroke color for the add sign.
@IBInspectable public var strokeColor: UIColor = UIColor.blackColor()

/// Line width for the add sign / checkmark.
@IBInspectable public var lineWidth: CGFloat = 2.0

/// When set to `true` the button will display a checkmark. When `false` an add sign.
@IBInspectable public var added: Bool = false

/// The additional spacing between the border of the view and the add sign / checkmark.
@IBInspectable public var margin: CGFloat = 8.0

Additionally there is convenience method to add a border to your button.

border(width:color:cornerRadius)

Requirements

  • iOS 8.0
  • Swift 2.0

Installation

AddButton is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "AddButton"

Author

Created and maintained by @svenbacia

License

AddButton is available under the MIT license. See the LICENSE file for more info.

About

Simple add/checkmark button written in Swift

Resources

License

Stars

Watchers

Forks

Packages

No packages published