ios开发设置button的选中状态图片
可以在故事版中设置好所需要的图片,然后现在h文件中声明按钮的属性和方法
- (IBAction)moodViewShow:(id)sender;
@property (weak, nonatomic) IBOutlet UIButton *faceBtn;
并且与故事版完成连接,然后在按钮的方法里设置选中的状态
- (IBAction)moodViewShow:(id)sender
{
if ([self.faceBtn isSelected]) {//如果是选中状态就置为no,
[self.faceBtn setSelected:NO];
self.faceView.frame = CGRectMake(0.0f,CGRectGetHeight(self.view.frame),CGRectGetWidth(self.view.frame),150);
}
else
{
[self.faceBtn setSelected: YES];//选中状态置为yes
self.faceView.frame = CGRectMake(0.0f,CGRectGetHeight(self.view.frame)-175,CGRectGetWidth(self.view.frame),150);
}
}