scu*_*cud 62 iphone uibutton uiswitch
是否有一种方法可以为开关状态实现带有自定义图形的UISwitch?或者作为另一种选择,UIButton具有UISwitch功能?
pgb*_*pgb 102
UIButton 已经支持"切换"功能.
只需在Interface Builder中为"选定状态配置"设置不同的图像,并使用selected属性UIButton来切换其状态.
det*_*man 13
将图像设置为在选定状态下显示:
[button setImage:[UIImage imageNamed:@"btn_graphics"] forState:UIControlStateSelected];
然后在内部选择器上触摸,设置:
button.selected = YES;
如果你想取消另一个按钮的选择,请设置:
otherButton.selected = NO;
要构建PGB和nurne上面所说的内容,在设置状态并附加选择器(事件方法)之后,您可能希望将此代码放在该选择器中.
- (IBAction)cost:(id)sender 
{
    //Toggle current state and save
    self.buttonTest.selected = !self.buttonTest.selected;
    /**
     The rest of your method goes here.
     */
}
| 归档时间: | 
 | 
| 查看次数: | 32001 次 | 
| 最近记录: |