简体   繁体   English

按下时如何更改iPhone上按钮的默认颜色?

[英]How can I change the default color of the button on iPhone when pressed?

The default color when a button is pressed on Iphone is blue. 在Iphone上按下按钮时的默认颜色是蓝色。 How can I change to some other color? 如何更改为其他颜色?

The same applies to the case when I select a row of UITableViewCell. 当我选择一行UITableViewCell时,情况也是如此。 How can I change the color when selected? 选择后如何更改颜色?

Thanks. 谢谢。

In the case of the UIButton, I think you need to provide your own images for the highlighted state. 对于UIButton,我认为您需要为突出显示状态提供自己的图像。 Many of the controls in the iPhone OS like the UIToolbar and UINavigationBar provide a "tint color" that you can change to customize their appearance. iPhone OS中的许多控件(如UIToolbar和UINavigationBar)都提供了“淡色”,您可以更改它们以自定义其外观。 The UIButton has a couple of predefined appearances, like "Rounded Button", but most of the time I end up using custom images for mine. UIButton有一些预定义的外观,例如“圆形按钮”,但是大多数时候我最终还是使用自定义图像。

I'm not sure about the UITableViewCell - you might need to subclass it and draw the selected state yourself. 我不确定UITableViewCell-您可能需要对其进行子类化并自行绘制所选状态。 There may be a "background image for state" that you could change instead, though. 但是,可能会有“状态的背景图像”可以更改。

Sorry that's really not the best news. 抱歉,这不是最好的消息。 Maybe someone else knows a better way? 也许其他人知道更好的方法?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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