This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public protocol ClosureActionable: class { | |
func addTarget(target: AnyObject, forControlEvents controlEvents: UIControlEvents, closure: (Self) -> Void) -> AnyObject | |
func removeTarget(pointer: AnyObject) | |
} | |
extension UIControl: ClosureActionable { } | |
public extension ClosureActionable where Self: UIControl { | |
private var pointers: [TargetPointer] { | |
get { | |
if let existing = objc_getAssociatedObject(self, ClosureAssociatedKeys.Pointers) as? [TargetPointer] { return existing } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum TimePeriod { | |
case Seconds(Int) | |
case Minutes(Int) | |
case Hours(Int) | |
var timeInterval: NSTimeInterval { | |
switch self { | |
case .Seconds(let value): return NSTimeInterval(value) | |
case .Minutes(let value): return NSTimeInterval(value * 60) | |
case .Hours(let value): return NSTimeInterval(value * 60 * 60) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
open class NibLoadableView: UIView { | |
//MARK: - Public Properties | |
private(set) var customView: UIView! | |
//MARK: - Lifecycle | |
public required init?(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) | |
self.nibSetup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum SizeMatching { | |
case Width, Height, Both, None | |
} | |
class IKScrollView: UIScrollView { | |
//MARK: - Outlets | |
@IBOutlet private var contentView: UIView? | |
//MARK: - Properties | |
@IBInspectable var sizeMatching = SizeMatching.Width |