Skip to content

cruzdiego/DesignableButton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DesignableButton

Version License Platform

##Features

  • Designable on Storyboard
  • Touch Up Inside event can be directly linked to an IBAction. No need for subclassing, implementing UITapGestureRecognizer events or overriding touchesEnded method.
  • Flexible highlight behavior. Select which subviews you want to highlight at tap, no code needed.

Basic Usage

Drag an UIView to your Storyboard scene and change asign DesignableButton as its custom class

From there, you can insert subviews to it and asign IBActions to its events (being Touch Up Inside the most used).

Customizing it

Thanks to IBInspectables, you can customize the following properties right on Storyboard:

@IBInspectable var highlight:Bool = true

Determine if DesignableButton can be highlighted or not at tap. Default value is true.

@IBInspectable var highlightAlpha:CGFloat = 0.5

Alpha value applied to selected subviews (or entire DesignableButton if none is selected) on highlighted state. Default value is 0.5

@IBOutlet public var highlightableViews: [UIView]?

Collection of subviews selected to be highlighted at tap. If empty or nil (and highlight is true) entire DesignableButton is highlighted.

You can append subviews to this array either programatically or using Storyboard:

Requirements

  1. iOS 8.2 or newer
  2. Xcode version supporting Swift 2.1 syntax (7.1 or later)

Installation

Using CocoaPods:

pod "DesignableButton"

Or manually:

  1. Copy DesignableButton.swift to your project's bundle.

Author

Diego Cruz, diego.cruz@icloud.com

License

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

About

A simple customizable UIButton replacement with a built-in highlighting system.

Resources

License

Stars

Watchers

Forks

Packages

No packages published