I'm developing an iOS 4 application.
我正在开发一个iOS 4应用程序。
I'm using a custom uibutton to make an image clickable. When user taps over the image, it will disappear.
我正在使用自定义uibutton来使图像可点击。当用户点击图像时,它将消失。
It's not very pretty to see that the image gets black, then turns to its original color, and then disappear.
看到图像变黑,然后变成原始颜色然后消失,这不是很漂亮。
Is there a way to disable that effect?
有没有办法禁用这种效果?
4 个解决方案
#1
18
You will need to set the property adjustsImageWhenHighlighted
to NO:
您需要将属性adjustsImageWhenHighlighted设置为NO:
[button setAdjustsImageWhenHighlighted:NO];
Alternatively you can set the same image for all controlStates of the button.
或者,您可以为按钮的所有控件状态设置相同的图像。
#2
2
You need to set the property Shows Touch On Highlight to enabled.
您需要将属性Shows Touch On Highlight设置为启用。
Programmatically you can do that with:
以编程方式,你可以这样做:
[button setShowsTouchWhenHighlighted:YES];
#3
1
Since it's a custom button, you get to specify the image you want to show when it's highlighted. Create the image you want to show in that situation.
由于它是一个自定义按钮,因此您可以指定要在突出显示时显示的图像。创建要在该情况下显示的图像。
#4
0
If you are using interface builder just set the Highlighted and selected states to the same image as the default image.
如果您正在使用界面构建器,只需将突出显示和选定状态设置为与默认图像相同的图像。
#1
18
You will need to set the property adjustsImageWhenHighlighted
to NO:
您需要将属性adjustsImageWhenHighlighted设置为NO:
[button setAdjustsImageWhenHighlighted:NO];
Alternatively you can set the same image for all controlStates of the button.
或者,您可以为按钮的所有控件状态设置相同的图像。
#2
2
You need to set the property Shows Touch On Highlight to enabled.
您需要将属性Shows Touch On Highlight设置为启用。
Programmatically you can do that with:
以编程方式,你可以这样做:
[button setShowsTouchWhenHighlighted:YES];
#3
1
Since it's a custom button, you get to specify the image you want to show when it's highlighted. Create the image you want to show in that situation.
由于它是一个自定义按钮,因此您可以指定要在突出显示时显示的图像。创建要在该情况下显示的图像。
#4
0
If you are using interface builder just set the Highlighted and selected states to the same image as the default image.
如果您正在使用界面构建器,只需将突出显示和选定状态设置为与默认图像相同的图像。