.h  文件中

@property (strong, nonatomic) IBOutletUIButton *publishBtton;

@property (strong, nonatomic) IBOutletUIButton *timeLineButton;

@property (strong, nonatomic) IBOutletUIButton *chatButton;

@property (strong, nonatomic) IBOutletUIButton *topicButton;

.m 文件中

- (void)viewDidLoad

{

[superviewDidLoad];

_buttonArray=@[_publishBtton,_timeLineButton,_chatButton,_topicButton];

[_publishBttonsetImage:[UIImageimageNamed:@"publish"] forState:UIControlStateNormal];

[_timeLineButtonsetImage:[UIImageimageNamed:@"timeLineAfter"] forState:UIControlStateNormal];

[_chatButtonsetImage:[UIImageimageNamed:@"chatBefore"] forState:UIControlStateNormal];

[_chatButtonsetImage:[UIImageimageNamed:@"chatAfter"] forState:UIControlStateSelected];

[_topicButtonsetImage:[UIImageimageNamed:@"topicBefore"] forState:UIControlStateNormal];

[_topicButtonsetImage:[UIImageimageNamed:@"topicAfter"] forState:UIControlStateSelected];

}

-(void)changeButtonState:(UIButton *)button buttons:(NSArray *)buttonArray

{

for (UIButton* b in buttonArray)

{

b.selected=NO;

}

button.selected=YES;

}

//点击按钮事件

- (IBAction)changeView:(UIButton *)sender

{

[selfchangeButtonState:sender buttons:_buttonArray];

switch (sender.tag) {

case 400:

{

[_timeLineButtonsetImage:[UIImageimageNamed:@"timeLineBefore"] forState:UIControlStateNormal];

break;

}

case401:

{

[_timeLineButtonsetImage:[UIImageimageNamed:@"timeLineAfter"] forState:UIControlStateSelected];

break;

}

case402:

{

[_timeLineButtonsetImage:[UIImageimageNamed:@"timeLineBefore"] forState:UIControlStateNormal];

break;

}

case 403:

{

[_timeLineButtonsetImage:[UIImageimageNamed:@"timeLineBefore"] forState:UIControlStateNormal];

break;

}

default:

break;

}

}

05-11 19:28