Swift Moth

swift-1.2

A 3-post collection

Page 1 of 1

Calculate height of multi-line UILabel

func heightForLabel(#fontSize: CGFloat, labelWidth: CGFloat) -> CGFloat { let label:UILabel = UILabel(frame: CGRectMake(0, 0, labelWidth, CGFloat.max)) label.numberOfLines = 0 label.lineBreakMode = NSLineBreakMode. »

Jack Chen S Y on UI, swift-1.2, UILabel 03 July 2015

Learn swift casting from examples

The first thing boring swift beginners is the weird ? and ! marks in different positions. Sometimes they follow as and followed by a class name such as »

Jack Chen S Y on Casting, Optional, swift-1.2 01 June 2015

Customize init() method in subclasses of UIViewController

We usually do some setup during initialising a view controller, under UIViewController. It’s pretty simple to override init() method in objective c, like: - (id) »

Jack Chen S Y on swift-1.2, UIViewController, objc-swift, initializer 24 May 2015
Page 1 of 1
Swift Moth © 2021
Proudly published with Ghost