传多个枚举参数

typedf     NS_OPTIONS (NSUInteger , PDImageButtonState) {

                   PDImageButtonStateNormal  = 0,

                   PDImageButtonStateHighlighht  = 1 << 0;

                  PDImageButtonStateDisabled = 1 << 1;

};


- (void)setImage:(UIImage *)image forState: (PDImageButtonState)state

{

      _image = state & PDImageButtonStateNormal ? image : nil;                    //把传进来的参数相与,就能判断传进来的是什么了

       _highlightImage = state & PDImageButtonStateHighlight  ? image : nil;

       _disabledImage = state & PDImageButtonStateDisabled ? image : nil;

}

你可能感兴趣的:(传多个枚举参数)