我的 iPhone 应用程序中有 4 个按钮,它们是这样添加的:
UIImage *button1Image = [UIImage imageNamed:@"friends.png"];
button1 = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
self.button1.tag=102;
[button1 setImage:button1Image forState:UIControlStateNormal];
[button1 setImage:[UIImage imageNamed:@"friends_hvr.png"] forState:UIControlStateSelected | UIControlStateHighlighted];
self.button1.frame = CGRectMake(90,5, 70,32);
[button1 addTarget:self action:@selector(friends:) forControlEvents:UIControlEventTouchUpInside];
我想让我的按钮状态选择一段时间,以便在选择按钮时更改背景,即直到选择下一个按钮。但对我来说,它只在某些时候起作用,一眨眼。我需要在行动中坚持这一点。我是这样做的:
-(void)friends:(id)sender
{
[button1 setSelected:YES];
有谁能够帮助我?