Drawing a custom button

I am drawing a custom button:

UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom];
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?

Answers


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

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

Need Your Help

Can Alter Table Engine = InnoDB be run on multiple tables at the same time?

mysql phpmyadmin innodb myisam

When it comes to MySQL and PHPMyAdmin, I'm not a novice, but I'm closer to novice than expert. Hopefully what I ask for is doable, and that someone will provide me with a simple, cut-n-paste SQL qu...

Wordpress permalinks are ignoring Unicode characters in URL

wordpress unicode iis-6 windows-server-2003

There is some problem with pretty permalinks of wordpress on my server.