LoginSignup
18
19

More than 5 years have passed since last update.

Swift2でのautoresizingMaskの複数指定方法

Posted at

経緯

Objective-CのコードをSwift2で書き直していた時に少しハマったのでメモ

Objective-CとSwift1.2以前での指定方法

Objective-CやSwift1.2では以下のように指定していました。

UIView *view = [[UIView alloc]init];
view.autoresizingMask 
    = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

swift1.2

let view = UIView()
view.autoresizingMask = .FlexibleWidth | .FlexibleHeight

Swift2.0での指定方法

それがSwift2.0では以下の様な指定方法になりました。

swift2.0

let view = UIView()
view.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]

参考

stack overflow(http://stackoverflow.com/questions/30867325/binary-operator-cannot-be-applied-to-two-uiviewautoresizing-operands)

18
19
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
19