// 1.create UIVIEw programmetically var myVIEw = UIVIEw(frame: CGRectMake(100,100,100)) // 2.add myVIEw to UIVIEw hIErarchy self.vIEw.addSubvIEw(myVIEw) // 3. add action to myVIEw let gesture = UITapGestureRecognizer(target: self,action: "someAction:") // or for swift 2 + let gestureswift2AndHigher = UITapGestureRecognizer(target: self,action: #selector (self.someAction (_:))) self.myVIEw.addGestureRecognizer(gesture) func someAction(sender:UITapGestureRecognizer){ // do other task } // or for Swift 3 func someAction(_ sender:UITapGestureRecognizer){ // do other task }@H_403_1@ 总结
以上是内存溢出为你收集整理的Swift,UIView触摸事件在控制器全部内容,希望文章能够帮你解决Swift,UIView触摸事件在控制器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)