3 Auto Layout
Auto Layoutは2つの画面が互いにどのように影響しあうかを指定しておく事で、実際の画面配置をiOS側に任せるという仕組みです。
この2つの画面間の配置取り決めの事を制約と呼び、NSLayoutConstraintクラスで表現されます。
3.1 制約
実際に-viewDidLoadで各UILabelに制約を設定してみましょう。
class ViewController: UIViewController {・・・
override func viewDidLoad() {
・・・
NSNotificationCenter.defaultCenter().addObserver(self,
selector:"contentSizeCategoryDidChange:",
name:UIContentSizeCategoryDidChangeNotification, object:nil)
↓Auto Layout機能追加
var constraints = [NSLayoutConstraint]() ← 制約群収納用
var upperObject:AnyObject = self.topLayoutGuide
for label in self.lables {
↓labelに対しAuto Layoutを有効にする
label.setTransla
この記事は会員限定です。会員登録をすると続きをお読みいただけます。
ログイン / 新規登録