Изменить цвет фона UIButton при выделении

Привет, я хочу изменить цвет фона UIButton, который пользователь нажимает на кнопку.

Я показываю цвет фона с помощью градиента, когда пользователь нажимает «Мне нужно изменить цвет градиента».

[btn setTitle: @"Next" forState:UIControlStateNormal];
CAGradientLayer *gradient = [CAGradientLayer layer];            
gradient.frame = btn.bounds;
gradient.cornerRadius = 10.0f;
locations = [[NSArray alloc] initWithObjects: 0.0f, 0.0f, 0.0f,0.0f, nil]; 
[gradient setLocations:locations];
colorNext = [[NSArray alloc] initWithObjects:…., nil]; 
gradient.colors = colorNext;
[locations release];
[btn.layer insertSublayer:gradient atIndex:0];
btn.titleLabel.textColor = [UIColor blackColor];
26
задан mxcl 27 January 2011 в 12:20
поделиться