Reputation: 21
In all my application i have UIButton with UIButtonTypeSystem.
For ios7 I want to set buttons appearance programatically.
for normal state i need white background with blue border color
for highlighted state i need grey background with blue border color
(and for disabled state i need white background with grey border)
I created image for each state (containing background and border color)and I set them using the UIButton's method setBackgroungImage:forState:.
but when the button is in highlight state i get this button style
the only way to overcome this behavior that i found is to change all the application buttons type from UIButtonTypeSystem to UIButtonTypeCustom. meaning passing on all the application xib's
is there another way of doing so without changing all application buttons type
thanks roi
Upvotes: 2
Views: 1118
Reputation: 21
Hello you can set you're button programatically like that:
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(aMethod:)
forControlEvents:UIControlEventTouchUpInside];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[buuton setBackgroundColor:[UIColor colorWithRed:(255/255.0) green:(180/255.0) blue:(200/255.0) alpha:1]];
[view addSubview:button];
Upvotes: 1