简体   繁体   中英

How to set UIButton's highlighted property to NO?

While i am touching a UIButton how can I make it not highlighted. I don't want to just completely shun the highlighted feature however. I just want to make the highlighted stop when I begin to drag. I have tried this though

-(IBAction)stopHighlighting:(UIButton *)sender// i hooked this up to IB for touchDragInside
{

sender.highlighted=NO;
//this doesnt work at all
}

The problem is that the system will override your logic. It calls the target method before darkening the image for highlight so basically you will set it to NO and then it will set it back to YES and you will see nothing. You have two options:

1) Use dispatch_async to delay your call to highlight until after the system has set it.

2) Disable the runtime highlighting and switch your images manually.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM