swift UIImageView
2016-09-22 11:40
288 查看
创建显示UIImageView:
声明var imageview:UIImageView!
在viewDidLoad()方法中初始化
self.imageview =
UIImageView(frame:CGRect(x:20,y:120,width :280,height:280))
imageview.backgroundColor =
UIColor.blueColor()
self.view.addSubview(imageview)
添加点击事件:
第一步:
//Enable用户交互
self.imageview.userInteractionEnabled =true
//添加手势识别
self.imageview.addGestureRecognizer(UITapGestureRecognizer(target:self,
action: "touchSelect:"))
第二步:
添加手势识别方法
func touchSelect(sender:UITapGestureRecognizer)->Void{
print("你点击了我")
}
声明var imageview:UIImageView!
在viewDidLoad()方法中初始化
self.imageview =
UIImageView(frame:CGRect(x:20,y:120,width :280,height:280))
imageview.backgroundColor =
UIColor.blueColor()
self.view.addSubview(imageview)
添加点击事件:
第一步:
//Enable用户交互
self.imageview.userInteractionEnabled =true
//添加手势识别
self.imageview.addGestureRecognizer(UITapGestureRecognizer(target:self,
action: "touchSelect:"))
第二步:
添加手势识别方法
func touchSelect(sender:UITapGestureRecognizer)->Void{
print("你点击了我")
}
相关文章推荐
- swift中UIImageView的使用
- Swift-UIImageView使用小结
- Swift3.0-UILabel、UIButton、UIImageView创建以及使用
- swift - UIImageView 的使用
- UIImageview and UIImage 之Swift学习
- Swift - 图像控件(UIImageView)的用法
- Swift-UIImageView简单动画实现原理
- 为UIImageView添加响应点击事件(Swift)
- swift学习笔记之UIImageView
- Swift -UIButton和UIImageView的用法
- Swift UIImageView简单动画
- Swift UIImageView 子View接受点击
- swift 实践- 09 -- UIImageVIew
- ios,swift 给控件(UIImageView,UIView,UILable)添加响应事件
- Swift_UI:(一)、UILabel、UIButton、UIImageView、UITextFidld、UISwitch
- Swift动态添加UIImageView并添加事件
- UIImageView圆角设置swift
- swift学习笔记-UI篇之UIImageView
- Swift UIImageView和UISlider组合
- Swift基础之UIImageView(都是2.2版本)