让UIButton在按下时没有高亮效果
How are you setting the images for the different UIControlStates
on the button? Are you setting a background image for UIControlStateHighlighted
as well as UIControlStateSelected
?
UIImage *someImage = [UIImage imageNamed:@"SomeResource.png"]; [button setBackgroundImage:someImage forState:UIControlStateHighlighted]; [button setBackgroundImage:someImage forState:UIControlStateSelected];
If you're setting the selected state on the button touch down event rather than touch up inside, your button will actually be in a highlighted+selected state, so you'll want to set that too.
[button setBackgroundImage:someImage forState:(UIControlStateHighlighted|UIControlStateSelected];
Edit:
To sum up my remarks in the comments and to address the code you posted...you need to set your background images for the full UIControl
state that you're in. According to your code snippet, this control state would be disabled+selected+highlighted for the duration of the network operation. This means that you would need to do this:
[button setBackgroundImage:someImage forState:(UIControlStateDisabled|UIControlStateHighlighted|UIControlStateSelected];
If you remove the highlighted = YES
, then you would need this:
[button setBackgroundImage:someImage forState:(UIControlStateDisabled|UIControlStateSelected];
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步