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

ObjectResult<Nullable<DateTime>> to IEnumerable<DateTime>?

sql-server entity-framework stored-procedures ienumerable

I've attached a stored procedure (see my previous question w/proc code) to my Entity Framework model with function import, selecting "Scalars: DateTime" to get a collection of DateTimes as the ret...

It is possible to use WCF + DTO's + Automapper?

c# asp.net-mvc wcf automapper

I want to use automapper with a structure that uses WCF + DTO's but I want to know how the question of the eager loading with entity framework 4.0 work with the mappings of the automap.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.