简体   繁体   中英

Xcode disable UIButton title fade when tapped

When I tap or hold down on any of my UIButtons, their alpha seems to fade to about 0.1. I never added this functionality in, so I'm assuming it's automatic.

How do I disable this so that my button doesn't fade when tapped or held down? I want my button to remain at alpha 1 all the time.

I've tried button.adjustsImageWhenHighlighted = NO; to no avail, as well as a few other suggestions on here.

Did you try using the same image for both the "normal" and "highlighted" states?

Maybe showsTouchWhenHighlighted also affects the situation.

Are you using background images for your buttons too?

Are you disabling the button upon tapping? Disabling also affects appearance (unlike userInteractionEnabled ).

Are you using IB/Storyboards?

As you can see, there is a number of factors that can play a role into what's happening.

Any code you can show with specifics of your situation?

Edit: If you are not using an image (you mentioned adjustsImageWhenHighlighted ), then just set the button type to "custom" in IB. You won't get the system provided "default" behavior.

只需在“绘图”部分旁边的按钮配置中上调“已禁用”调整MainStory板中的图像

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