9.14 按钮总结

2017-07-14  本文已影响0人  小码农杰哥

当点击切换不同状态时:

1.不用Bool值:

_collectBtn setBackgroundImage:[UIImage imageNamed:@"收藏按钮"] forState:UIControlStateNormal];

[_collectBtn setBackgroundImage:[UIImage imageNamed:@"已收藏"] forState:UIControlStateSelected];

点击方法写

sender.selected = !sender.selected;

if (sender.selected) {

}

else{

}

2.使用Bool值:

全局定义一个 Bool isRect;

if (isRect) {

isRect = NO;

[_loginview.rememberButton setImage:[UIImage imageNamed:@"记住密码未选中"] forState:UIControlStateNormal];

}

else{

isRect = YES;

[_loginview.rememberButton setImage:[UIImage imageNamed:@"记住密码"] forState:UIControlStateNormal];

}

上一篇 下一篇

猜你喜欢

热点阅读