首页 > 代码库 > UIButton的selected设为TRUE时在按下时显示自定义的背景图
UIButton的selected设为TRUE时在按下时显示自定义的背景图
在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];
经研究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];
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。