请看一下这个简单的Swift代码:
UIView.animate(withDuration: duration, delay: interButtonDelay * Double(expanding ? index : index + 1), options: [], animations: {
button.transform = expanding ? .init(scaleX: self.scale, y: self.scale) : .identity
button.alpha = expanding ? 0.0 : 1.0
}, completion: nil)
这里将一个空数组传递给options
参数。我想找出与此相同的正确Objective-C是什么。我认为它应该传递0,但我想完全确定。不幸的是,文档没有说明这一点。
答案 0 :(得分:7)
创建了Swift的OptionSet
以使位掩码更加舒适。在Swift中,你将组合值拼写成一个集合;在Objective-C中,它是一个用位运算符构建的整数值:
NSUInteger options = UIViewAnimationOptionLayoutSubviews | UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveEaseOut;
因此,相当于空OptionSet
的Objective-C确实只是0。