Skip to content

UIButton

按钮控件。使用 UIButton.buttonWithType(0)new UIButton(frame) 创建。点击需在 JSB.defineClass 的实例方法 中定义 selector(如 toggleSample:),方法名必须以冒号结尾,并通过 addTargetActionForControlEvents(self, 'toggleSample:', 1<<6) 绑定(1<<6 为 TouchUpInside)。

方法参数返回值说明
buttonWithType(buttonType)buttonType: number(0 为 System)UIButton创建按钮。
方法/属性说明
setTitleForState(title, state)设置标题(state 0 为 Normal)。
setTitleColorForState(color, state)设置标题颜色。
setImageForState(image, state)设置图片。
setBackgroundImageForState(image, state)设置背景图。
addTargetActionForControlEvents(target, action, event)target 通常为 self,action 为 ‘methodName:‘,event 1<<6 为点击。