利用JSPatch为controller添加View

来源:互联网 发布:数值的整数次方 java 编辑:程序博客网 时间:2024/06/14 01:04
小代码片段
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('这是动态添加的按钮响应事件')  },})
0 0
原创粉丝点击