请帮助我理解以下 Swift 构造:
struct UIViewAnimationOptions : RawOptionSetType {
init(_ rawValue: UInt)
init(rawValue rawValue: UInt)
static var LayoutSubviews: UIViewAnimationOptions { get }
static var AllowUserInteraction: UIViewAnimationOptions { get }
static var BeginFromCurrentState: UIViewAnimationOptions { get }
static var Repeat: UIViewAnimationOptions { get }
static var Autoreverse: UIViewAnimationOptions { get }
static var OverrideInheritedDuration: UIViewAnimationOptions { get }
}
我不明白结构属性如何与结构本身属于同一类型。为什么所有的 setter/getter 都是空的?这东西是怎么工作的?
下面是我如何在我的代码中使用这种动画结构的简短示例:
let options = UIViewAnimationOptions.Autoreverse | UIViewAnimationOptions.Repeat
...
UIView.animateWithDuration(1.0, delay: 0.0, options: options, animations: {
...
}, completion: nil)
最佳答案
这些是 static
属性,与结构的实例无关。 (另外,属性可能被计算或存储;你不知道。并且有可能让一个结构具有它自己类型的计算实例属性。)
关于Swift 结构属性与结构本身的类型相同。递归?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30248683/