有一次我在Swift 3之前猜测下面的代码行用于编译,但现在却没有:
var directions: MGTransitioningOptions = [.DirectionUp]
它会出现以下错误:"上下文类型' MGTransitioningOptions'不能与数组文字"
一起使用以下是创建MGTransitioningOptions的结构的代码:
struct MGTransitioningOptions: OptionSet {
internal let rawValue: Int
init(rawValue: Int) {self.rawValue = rawValue}
static let DirectionUp = MGTransitioningOptions(rawValue: 1<<1)
static let DirectionDown = MGTransitioningOptions(rawValue: 1<<2)
static let DirectionLeft = MGTransitioningOptions(rawValue: 1<<3)
static let DirectionRight = MGTransitioningOptions(rawValue: 1<<4)
static let AlphaChange = MGTransitioningOptions(rawValue: 1<<5)
static let BlurBackground = MGTransitioningOptions(rawValue: 1<<5)
static let Dissolve = MGTransitioningOptions(rawValue: 1<<6)
static let Interactive = MGTransitioningOptions(rawValue: 1<<7)
}