请看一下这个简单的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,但我想完全确定。 不幸的是,文档没有说明这一点。
Please take a look at this simple Swift code:
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)Here an empty array is passed into the options parameter. I would like to find out what is the correct Objective-C equivalent to doing this. I assume it should be passing 0, but I want to be completely sure. Unfortunately the docs not telling anything regarding this.
最满意答案
创建Swift的OptionSet是为了使位掩码更加舒适。 在Swift中,你将组合值拼写成一个集合; 在Objective-C中,它是一个用位运算符构建的整数值:
NSUInteger options = UIViewAnimationOptionLayoutSubviews | UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveEaseOut;因此,相当于空OptionSet的Objective-C实际上只是0。
Swift's OptionSet was created to make bitmasks more pleasant to use. In Swift, you spell the combined value as if it were a collection; in Objective-C, it's an integral value, built with bitwise operators:
NSUInteger options = UIViewAnimationOptionLayoutSubviews | UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveEaseOut;The Objective-C equivalent to an empty OptionSet is therefore indeed just 0.
更多推荐
发布评论