addObserver(IPHONE_DID_UNLOCKED) {
if isOnSkin {
locked = false
}
}
addObserver(WATCH_OFF_SKIN) {
locked = true
}
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
subviewB.translatesAutoresizingMaskIntoConstraints = false | |
view.addSubview(subviewB) | |
constraints.append(NSLayoutConstraint(item: subviewB, attribute: .top, relatedBy: .equal, | |
toItem: view, attribute: .top, multiplier: 1.0, constant: 150)) | |
// subviewA.top = 1.0 * view.top + 150 | |
constraints.append(NSLayoutConstraint(item: subviewB, attribute: .bottom, relatedBy: .equal, | |
toItem: view, attribute: .bottom, multiplier: 1.0, constant: -150)) | |
// subviewA.bottom = 1.0 * view.bottom - 150 | |
constraints.append(NSLayoutConstraint(item: subviewB, attribute: .left, relatedBy: .equal, | |
toItem: view, attribute: .left, multiplier: 1.0, constant: 100)) |
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
subviewA.translatesAutoresizingMaskIntoConstraints = false // 這是純程式碼寫 Auto Layout 的大雷:必須設定這一行! | |
view.addSubview(subviewA) | |
var constraints = [NSLayoutConstraint]() | |
constraints.append(NSLayoutConstraint(item: subviewA, attribute: .centerX, relatedBy: .equal, | |
toItem: view, attribute: .centerX, multiplier: 1.0, constant: 0)) | |
// subviewA.centerX = 1.0 * view.centerX + 0 即 subviewA.centerX = view.centerX | |
constraints.append(NSLayoutConstraint(item: subviewA, attribute: .centerY, relatedBy: .equal, | |
toItem: view, attribute: .centerY, multiplier: 1.0, constant: 0)) | |
// subviewA.centerY = 1.0 * view.centerY + 0 即 subviewA.centerY = view.centerY | |
constraints.append(NSLayoutConstraint(item: subviewA, attribute: .width, relatedBy: .equal, |
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
//: Playground - noun: a place where people can play | |
// 1. Proposed Error Handling | |
enum Error: ErrorType { | |
case IsNegative(String) | |
case IsPositive(String) | |
} | |
func isZero(number: Int) -> Error? { | |
if number != 0 { |
NewerOlder