Declaring and using a bit field enum in Swift

前端 未结 14 2001
余生分开走
余生分开走 2020-12-13 09:24

How should bit fields be declared and used in Swift?

Declaring an enum like this does work, but trying to OR 2 values together fails to compile:

enum         


        
14条回答
  •  借酒劲吻你
    2020-12-13 09:35

    Do bitwise operation using raw value then create a new enum object using the result.

    let mask = UIViewAutoresizing(rawValue: UIViewAutoresizing.FlexibleWidth.rawValue|UIViewAutoresizing.FlexibleHeight.rawValue) self.view.autoresizingMask = mask

提交回复
热议问题