我需要知道Swift语言是否有办法实现标记枚举中某些元素的功能。例如,我在Swift enum中有一组属性,其中一些属性可以设置动画,而其他属性则不能。我想要这样的东西:
public enum Property: String {
case prop1,
case prop2 @animatable,
case prop3 @animatable,
case prop4,
case prop5 @animatable,
...
...
...
case prop100
}
然后在函数中我可以传递一个参数,比如:
func animate(_ prop: Property @animatable, startTime:CFTimeInterval, duration:CFTimeInterval) {
}