在UIButton的selected设为TRUE后,需要在按钮高亮时,显示自定义的背景图。
经研究hightLighted和selected这两个状态是可以重叠的,就是button可以同时处于selectec和highlighted两个状态下。
从UIControlState的定义也可以看出:
typedef NS_OPTIONS(NSUInteger, UIControlState) {
UIControlStateNormal = 0,
UIControlStateHighlighted = 1 << 0, // used when UIControl isHighlighted is set
UIControlStateDisabled = 1 << 1,
UIControlStateSelected = 1 << 2, // flag usable by app (see below)
UIControlStateApplication = 0x00FF0000, // additional flags available for application use
UIControlStateReserved = 0xFF000000 // flags reserved for internal framework use
};
设置这种状态重叠情景时的背景图:
[button setBackgroundImage:[UIImage imageNamed:@"seled_highLight.png"] forState:UIControlStateSelected| UIControlStateHighlighted];UIButton的selected设为TRUE时在按下时显示自定义的背景图,布布扣,bubuko.com
UIButton的selected设为TRUE时在按下时显示自定义的背景图
原文:http://blog.csdn.net/gaoyp/article/details/28605561