更改枚举类型值

时间:2012-07-16 07:57:53

标签: iphone objective-c ios xcode enums

你好我正在使用一个库。它有一些嵌入在枚举中的选项,但我无法弄清楚如何配置它们。该库名为PPRevealSideViewController。 它有一个属性:

@property (nonatomic, assign) PPRevealSideOptions options;

这是枚举代码:

enum {
    PPRevealSideOptionsNone = 0,
    PPRevealSideOptionsShowShadows = 2 << 1, /// Disable or enable the shadows. Enabled by default
    PPRevealSideOptionsBounceAnimations = 1 << 2, /// Decide if the animations are boucing or not. By default, they are
    PPRevealSideOptionsCloseCompletlyBeforeOpeningNewDirection = 1 << 3, /// Decide if we close completely the old direction, for the new one or not. Set to YES by default
    PPRevealSideOptionsKeepOffsetOnRotation = 1 << 4, /// Keep the same offset when rotating. By default, set to no
    PPRevealSideOptionsResizeSideView = 1 << 5, /// Resize the side view. If set to yes, this disabled the bouncing stuff since the view behind is not large enough to show bouncing correctly. Set to NO by default
};
typedef NSUInteger PPRevealSideOptions;

非常感谢!

2 个答案:

答案 0 :(得分:2)

obj.options = opt0 | opt1 | ... etc

例如:obj.options = PPRevealSideOptionsBounceAnimations | PPRevealSideOptionsResizeSideView;

答案 1 :(得分:1)

我为此目的制作了这个控制器的文档。好吧,我的坏,这个方法不是很突出,但确实存在: 您可以使用- (void) resetOption:(PPRevealSideOptions)option;重置选项(后面,它是低级别:_options ^= option;) 或者使用- (void) setOption:(PPRevealSideOptions)option设置选项。甚至还有一个setOptionS方法;)