2017-08-30 28 views
2

请看看这个简单的银行代码:什么是Objective-C相当于一个空的Swift OptionSet?

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

Ç枚举是整数,所以0是一个有效的值通过 – Mindaugas

回答

7

斯威夫特的OptionSet被创建使掩码更愉快使用。在Swift中,你将合并后的价值拼凑成一个集合;在Objective-C,这是一个整数值,用位运算符建:

NSUInteger options = UIViewAnimationOptionLayoutSubviews | UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveEaseOut; 

Objective-C的等效于一个空OptionSet因此确实只是0

相关问题