码迷,mamicode.com
首页 > 其他好文 > 详细

UIButton在处于selected的情况下点击的问题

时间:2015-07-28 20:19:54      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:

    [button setBackgroundImage:backImage forState:UIControlStateNormal];
    [button setBackgroundImage:backImage forState:UIControlStateHighlighted];
    [button setBackgroundImage:selecetedBackImage forState:UIControlStateSelected | UIControlStateHighlighted];
    [button setBackgroundImage:selecetedBackImage forState:UIControlStateSelected];
    [button setImage:iconImage forState:UIControlStateNormal];
    [button setImage:iconImage forState:UIControlStateHighlighted];
    [button setImage:iconImage forState:UIControlStateSelected|UIControlStateHighlighted];
    [button setTitle:text forState:UIControlStateNormal];
    [button.titleLabel setFont:[UIFont systemFontOfSize:12.0]];

自定义tabbar用button替代tabbaritem遇到了一个问题。就是在选中button的情况下,再次点击button,会变成默认的图片,看起来很不美观。

 查了好久终于看到原来还是state的原因。

UIControlStateSelected | UIControlStateHighlighted
UIControlStateSelected

这俩代表的不同,UIControlStateSelected | UIControlStateHighlighted 是处于selected 的情况下,再次点击高亮的效果。

UIButton在处于selected的情况下点击的问题

标签:

原文地址:http://www.cnblogs.com/LoveJiaQi/p/4683583.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!