Latest 0.1.0
Homepage https://github.com/svenbacia/AddButton
License MIT
Platforms ios 8.0, requires ARC
Authors

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.

AddButton

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.

AddButton

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.

Latest podspec

{
    "name": "AddButton",
    "version": "0.1.0",
    "summary": "AddButton is a simple button which has two states. One will display an add sign, the other a checkmark.",
    "description": "AddButton is a simple UIButton which can be used in situations where an item can be added to a collection for example. The button has two states. One displays an add sign the other a checkmark.",
    "homepage": "https://github.com/svenbacia/AddButton",
    "license": "MIT",
    "authors": {
        "Sven Bacia": "[email protected]"
    },
    "source": {
        "git": "https://github.com/svenbacia/AddButton.git",
        "tag": "0.1.0"
    },
    "social_media_url": "https://twitter.com/svenbacia",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "resource_bundles": {
        "AddButton": [
            "Pod/Assets/*.png"
        ]
    }
}

Pin It on Pinterest

Share This