开发者

iPhone Buttons Question

开发者 https://www.devze.com 2023-02-08 13:43 出处:网络
Once I tap the button, its default highlight color is blue.How can you change the highlight co开发者_运维百科lor of a button.Either in interface builder or by code.In IB when you select the Button Att

Once I tap the button, its default highlight color is blue. How can you change the highlight co开发者_运维百科lor of a button. Either in interface builder or by code.


In IB when you select the Button Attributes of your UIButton choose "Highlighted State Configuration" (instead of "Default State Configuration") and select an image for the Background.

Or in code: [myButton setBackgroundImage:[UIImage imageNamed:@"imagename"] forState:UIControlStateHighlighted];

So you rather set an image, than set a color.

You might want to look into code examples of creating your custom UIButton ([UIButton buttonWithType:UIButtonTypeCustom]), using UIImage's stretchableImageWithLeftCapWidth:topCapHeight: instance method.

0

精彩评论

暂无评论...
验证码 换一张
取 消