Tin*_*yik 2 xcode cocoa-touch uibutton ios swift
我想在突出显示的状态图像中保留一个按钮,直到第二次触摸将其释放到正常状态.
我试过这个dispatch_async方法,但是再次点击后它就无法恢复到正常状态.
(我在Swift编码,所以performSelector:WithObject方法也不起作用.)
我将使用选定状态而不是突出显示.UIButton已经拥有该属性,因此您无需创建任何其他属性.
button.setImage(image, forState: UIControlState.Normal)
button.setImage(selectedImage, forState: UIControlState.Selected)
button.addTarget(self, action: "buttonTapped:", forControlEvents: UIControlEvents.TouchUpInside)
func buttonTapped(sender:UIButton)
{
sender.selected = !sender.selected;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1658 次 |
| 最近记录: |