// 单选
typedef NS_ENUM(NSInteger, UIViewAnimationTransition) {
UIViewAnimationTransitionNone,
UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight,
UIViewAnimationTransitionCurlUp,
UIViewAnimationTransitionCurlDown,
};
// 多选
typedef NS_OPTIONS(NSUInteger, UIViewAutoresizing) {
UIViewAutoresizingNone = 0,
UIViewAutoresizingFlexibleLeftMargin = 1 << 0,
UIViewAutoresizingFlexibleWidth = 1 << 1,
UIViewAutoresizingFlexibleRightMargin = 1 << 2,
UIViewAutoresizingFlexibleTopMargin = 1 << 3,
UIViewAutoresizingFlexibleHeight = 1 << 4,
UIViewAutoresizingFlexibleBottomMargin = 1 << 5
};
1.使用苹果枚举规范:NS_ENUM 和 NS_OPTIONS(宏定义)
2.好处:有了一个易读的名字了;确保所用的数据类型是开发者选定的类型,不会采用编译器所用的类型
3.对于switch语句处理枚举时 确保处理了所有的枚举值,同时不要添加defult语句,当有新的枚举值添加会产生警告信息。
网友评论