Swift and autoresizingMask
Short tutorial how to set autoresizingMask in Swift.
In Objective-C it looked something like this:
[code language=”objc”]
spinner.autoresizingMask = (UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin);
[/code]
In Swift you would rather write:
[code language=”objc”]
spinner.autoresizingMask = UIViewAutoresizing.FlexibleRightMargin | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleBottomMargin | UIViewAutoresizing.FlexibleTopMargin
[/code]
Bit masks syntax has been updated in Swift 2.0. Therefore, we can’t use the | operator anymore.
Your example in Swift 2 will look like:
spinner.autoresizingMask = [.FlexibleRightMargin, .FlexibleLeftMargin, .FlexibleBottomMargin, .FlexibleTopMargin]
Source: http://stackoverflow.com/q/30867325/730701