UIButton选择状态下长按时会变回原始状态

问题大概就像这样
这里写图片描述
(请无视那红字)
一般而言这是高亮状态的设置有所缺乏。完善代码如下:

[_pupilBtn setImage:[UIImage imageNamed:@"a1"]
             forState:UIControlStateNormal];
[_pupilBtn setImage:[UIImage imageNamed:@"a1"]
             forState:UIControlStateHighlighted];
[_pupilBtn setImage:[UIImage imageNamed:@"a2"]
             forState:UIControlStateSelected];
[_pupilBtn setImage:[UIImage imageNamed:@"a2"]
             forState:UIControlStateSelected | UIControlStateHighlighted];
posted @ 2017-09-23 17:48  MrYu4  阅读(60)  评论(0编辑  收藏  举报