简体   繁体   中英

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. How can I change to some other color?

The same applies to the case when I select a row of 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. 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. The UIButton has a couple of predefined appearances, like "Rounded Button", but most of the time I end up using custom images for mine.

I'm not sure about the UITableViewCell - you might need to subclass it and draw the selected state yourself. 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?

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