您的位置:首页 > Web前端 > JavaScript

利用JSPatch为controller添加View

2016-03-31 15:16 501 查看
小代码片段

defineClass('ViewController', {

viewDidLoad: function() {
self.ORIGviewDidLoad();
var width = require('UIScreen').mainScreen().bounds().width
var btn = require('UIButton').alloc().initWithFrame({x:0, y:100, width:width, height:50})
btn.setTitle_forState('这个按钮是通过JSPatch动态添加上去的啊', 0)
btn.addTarget_action_forControlEvents(self, "handleBtn:", 1 << 6)
btn.setBackgroundColor(require('UIColor').grayColor())
self.view().addSubview(btn)
},
handleBtn: function(sender) {
console.log('这是动态添加的按钮响应事件')
},
})
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: