开发者

Drawing a custom button

I am drawing a custom button:

UIButton *myButton = [UIButton buttonWithType:UIButt开发者_如何学JAVAonTypeCustom];
myButton.frame = CGRectMake(10,10,44,70);
[myButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[myButton setTitle:@"Order" forState:UIControlStateNormal];                   

When I am tapping on the button the back ground color is not changing. Do I need to use different images for normal and selected state? What is the trick here?


Yes, you need to use different images for different states:

[myButton setBackgroundImage:someUIImageRef forState:UIControlStateNormal];
[myButton setBackgroundImage:someOtherUIImageRef forState:UIControlStateHighlighted];


Yes. because you're using a custom button, you need to describe every single state manually or they will look like the normal state.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜