博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS-点击图片放大,再次点击返回原视图 类似查看相册的功能
阅读量:6867 次
发布时间:2019-06-26

本文共 1913 字,大约阅读时间需要 6 分钟。

hot3.png

@interface CommunityTableViewCell (){     CGRect oldframe ;}@end//开始touch-(void)touchesBegan:(NSSet
 *)touches withEvent:(UIEvent *)event{    UITouch *touch = [touches anyObject];    //如果touch的是图片    if ([touch.view isMemberOfClass:[UIImageView class]]) {        UIImageView *selectView =  (UIImageView *)touch.view;        [self showImage:selectView];    }    }//图片放大-(void)showImage:(UIImageView *)avatarImageView{       UIImage *image=avatarImageView.image;    UIWindow *window=[UIApplication sharedApplication].keyWindow;    UIView *backgroundView=[[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds] ;        oldframe=[avatarImageView convertRect:avatarImageView.bounds toView:window];        backgroundView.backgroundColor=[UIColor blackColor];    backgroundView.alpha=0;        UIImageView *imageView=[[UIImageView alloc]initWithFrame:oldframe];    imageView.image=image;    imageView.tag=1;        [backgroundView addSubview:imageView];    [window addSubview:backgroundView];        UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(hideImage:)];    [backgroundView addGestureRecognizer: tap];        [UIView animateWithDuration:0.3 animations:^{        imageView.frame=CGRectMake(0,(YiChe_Size.size.height-image.size.height*YiChe_Size.size.width/image.size.width)/2,YiChe_Size.size.width, image.size.height*YiChe_Size.size.width/image.size.width);        backgroundView.alpha=1;    } completion:^(BOOL finished) {            }];}//再次点击隐藏图片-(void)hideImage:(UITapGestureRecognizer*)tap{    UIView *backgroundView=tap.view;    UIImageView *imageView=(UIImageView*)[tap.view viewWithTag:1];    [UIView animateWithDuration:0.3 animations:^{        imageView.frame=oldframe;        backgroundView.alpha=0;    } completion:^(BOOL finished) {        [backgroundView removeFromSuperview];    }];}

转载于:https://my.oschina.net/ArtemisFang/blog/631131

你可能感兴趣的文章
Flutter Web - 目标全平台开发的Flutter再下一城!
查看>>
RAID-10 阵列的创建(软)
查看>>
小白学爬虫-批量部署Splash负载集群
查看>>
dubbo源码分析-服务端发布流程-笔记
查看>>
小菜鸡进阶之路-First week
查看>>
原创数据结构算法Flash动画演示课件-Action Script(AS)脚本实现
查看>>
基于Hyper-V3.0搭建XenDesktop7之九 部署虚拟应用之模板准备
查看>>
MyBatis之ResultMap标签
查看>>
kubernetes-1.11.0集群部署之master集群 (二)
查看>>
IDEA PermGen space内存溢出
查看>>
Create a RHEL6 PXE Installation Server
查看>>
【Android游戏开发二十二】(图文详解)游戏中灵活实现动画播放!
查看>>
桌面支持--Office2013没有Office Picture Manage怎么安装
查看>>
chmod修改文件权限失败
查看>>
数据结构与算法-->互为素数
查看>>
Linux系统学习方法——写给小白
查看>>
Nginx服务器报500 Internal Server Error错误
查看>>
链表的游标实现
查看>>
Linux下查看CPU信息、机器型号等硬件信息命令
查看>>
Lync Server 2013 部署 _ 部署简介及系统要求
查看>>