Presentation is loading. Please wait.

Presentation is loading. Please wait.

SUIImageView ZOOM 白仕云、iOS高级开发工程师 博客地址 http://blog.csdn.net/mjbaishiyun.

Similar presentations


Presentation on theme: "SUIImageView ZOOM 白仕云、iOS高级开发工程师 博客地址 http://blog.csdn.net/mjbaishiyun."— Presentation transcript:

1 SUIImageView ZOOM 白仕云、iOS高级开发工程师 博客地址

2 主要内容 1、复习UIImageView 2、复习UIButton 3、利用button蒙板实现图片缩放

3 加载图片 // 初始化imageview var imageview = UIImageView() // 设置显示frame
imageview.frame = CGRectMake(35, 100, 300, 300) //加载图片 var image = UIImage(named: "cat.jpg") //把加载的图片丢给imageview的image imageview.image = image //添加到父控件上,也就是self.view self.view.addSubview(imageview) 2018/11/21

4 蒙板 // 初始化UIButton(蒙板) var button:UIButton = UIButton.buttonWithType(UIButtonType.Custom) as UIButton //设置buttonframe var frame = imageview.frame button.frame = frame //添加到父控件 self.view.addSubview(button) //添加button响应方法 button.addTarget(self, action: "changeImage:", forControlEvents: UIControlEvents.TouchUpInside) 2018/11/21

5 设置圆角图片 // 初始化UIButton方法实现 func changeImage(sender:UIButton){
[UIView .beginAnimations("", context: nil)]; [UIView .setAnimationDelay(0.1)]; [UIView .setAnimationDuration(0.5)]; self.button.selected = !sender.selected if(self.button.selected == true){ self.imageview.frame = UIScreen.mainScreen().bounds }else if(self.button.selected == false){ self.imageview.frame = CGRectMake(100, 100, 100, 100) [UIView.commitAnimations];}} 2018/11/21

6 THANKS 本课程由 白仕云提供 CSDN网站:www.csdn.net 企业服务:http://ems.csdn.net/
人才服务: CTO俱乐部: 高校俱乐部: 程序员杂志: CODE平台: 项目外包: CSDN博客: CSDN论坛: CSDN下载:


Download ppt "SUIImageView ZOOM 白仕云、iOS高级开发工程师 博客地址 http://blog.csdn.net/mjbaishiyun."

Similar presentations


Ads by Google