我使用以下链接将颜色应用于按钮:
http://www.cimgf.com/2010/01/28/fun-with-uibuttons-and-core-animation-layers/
我应该如何将上述内容用于动态按钮?我的代码是:
int y=297;
for (int i=0; i < [phonesArray count]; i++) {
NSLog(@"%d phone number is :%@",i,[phonesArray objectAtIndex:i]);
UIButton *phoneButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[phoneButton setTitle:[phonesArray objectAtIndex:i] forState:UIControlStateNormal];
[phoneButton addTarget:self action:@selector(dailPhoneNo:) forControlEvents:UIControlEventTouchUpInside];
phoneButton.frame = CGRectMake( 11, y, 278, 42);
[scrollView addSubview:phoneButton];
y=y+60;
}
我也试过这个:
ColorfulButton *phoneButton = [[ColorfulButton alloc] init];
[phoneButton setTitle:[phonesArray objectAtIndex:i] forState:UIControlStateNormal];
[phoneButton addTarget:self action:@selector(dailPhoneNo:) forControlEvents:UIControlEventTouchUpInside];
phoneButton.frame = CGRectMake( 11, y, 278, 42);
[phoneButton setHighColor:[UIColor redColor]];
[phoneButton setLowColor:[UIColor orangeColor]];
[scrollView addSubview:phoneButton];
但是按钮没有出现在视图上。