This file contains hidden or 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 | |
| @IBDesignable | |
| class DemoView: UIView { | |
| override func awakeFromNib() { | |
| setupViews() | |
| } | |
This file contains hidden or 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
| @IBInspectable var integer: NSInteger = 10 | |
| @IBInspectable var float: CGFloat = 10 | |
| @IBInspectable var double: Double = 10 | |
| @IBInspectable var string: String = "string" | |
| @IBInspectable var bool: Bool = true | |
| @IBInspectable var point: CGPoint = CGPointMake(1, 0) | |
| @IBInspectable var rect: CGRect = CGRectMake(0, 0, 100, 100) | |
| @IBInspectable var color: UIColor = UIColor.redColor() | |
| @IBInspectable var size: CGSize = CGSizeMake(100, 100) | |
| @IBInspectable var image: UIImage = UIImage(named: "ElectricPeelLogo")! |
This file contains hidden or 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
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| NSNotificationCenter.defaultCenter().addObserver(self, selector: "preferredContentSizeChanged", name: UIContentSizeCategoryDidChangeNotification, object: nil) | |
| } | |
| func preferredContentSizeChanged () { | |
| NSLog("User wants the Font to Change") | |
| label.font = UIFont.preferredCustomFontForTextStyle(UIFontTextStyleBody) |
This file contains hidden or 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 | |
| extension UIFont { | |
| class func preferredCustomFontForTextStyle (textStyle: NSString) -> UIFont { | |
| let fontsDictionary = NSDictionary (contentsOfFile: NSBundle.mainBundle().pathForResource("CustomFontNames", ofType: "plist")!) | |
| let font = UIFontDescriptor.preferredFontDescriptorWithTextStyle(textStyle) | |
| let fontSize: CGFloat = font.pointSize | |
| if textStyle == UIFontTextStyleHeadline || textStyle == UIFontTextStyleSubheadline { | |
| if let boldFontName = (fontsDictionary.valueForKey("Bold Font Name") as String?) { |
This file contains hidden or 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
| customLabel.font = UIFont.preferredFontForTextStyle(UIFontTextStyleBody) |
This file contains hidden or 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 "NSArray+Statistics.h" | |
| @implementation NSArray (Statistics) | |
| - (NSNumber *)sum { | |
| NSNumber *sum = [self valueForKeyPath:@"@sum.self"]; | |
| return sum; | |
| } | |
| - (NSNumber *)mean { |