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?
Yes, you need to use different images for different states:
[myButton setBackgroundImage:someUIImageRef forState:UIControlStateNormal]; [myButton setBackgroundImage:someOtherUIImageRef forState:UIControlStateHighlighted];