点击图片,全屏显示,然后再点击屏幕一下,返回。

  没啥难的,直接上代码:

//

//  ViewController.m

//  Demo-hehe

//

//  Created by yyt on 16/4/25.

//  Copyright © 2016年 yyt. All rights reserved.

//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {

[super viewDidLoad];

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 80, self.view.bounds.size.width-40, 300)];

imageView.image = [UIImage imageNamed:@"11"];

imageView.userInteractionEnabled = YES;

[self.view addSubview:imageView];

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showZoomImageView:)];

tapGesture.numberOfTapsRequired=1;

[imageView addGestureRecognizer:tapGesture];

}

//缩放图片

-(void)showZoomImageView:(UITapGestureRecognizer *)tap

{

if (![(UIImageView *)tap.view image]) {

return;

}

UIView *bgView = [[UIView alloc] init];

bgView.frame = [UIScreen mainScreen].bounds;

bgView.backgroundColor = [UIColor blackColor];

[[[UIApplication sharedApplication] keyWindow] addSubview:bgView];

UITapGestureRecognizer *tapBgView = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapBgView:)];

[bgView addGestureRecognizer:tapBgView];

//必不可少的一步,如果直接把点击获取的imageView拿来玩的话,返回的时候,原图片就完蛋了

UIImageView *tempImageView = (UIImageView*)tap.view;

UIImageView *imageView = [[UIImageView alloc] initWithFrame:tempImageView.frame];

imageView.image = tempImageView.image;

[bgView addSubview:imageView];

[UIView animateWithDuration:0.5 animations:^{

CGRect frame = imageView.frame;

frame.size.width = bgView.frame.size.width;

frame.size.height = frame.size.width * (imageView.image.size.height / imageView.image.size.width);

frame.origin.x = 0;

frame.origin.y = (bgView.frame.size.height - frame.size.height) * 0.5;

imageView.frame = frame;

}];

}

-(void)tapBgView:(UITapGestureRecognizer *)tapBgRecognizer

{

[tapBgRecognizer.view removeFromSuperview];

}

@end

iOS开发——点击图片全屏显示的更多相关文章

  1. HBuilder开发iPad程序不能全屏显示的解决方法

    HBuilder开发iPad程序不能全屏显示的解决方法: targets选择HBuilder=>Deployment Info=> devices选择Universal即可

  2. 微信小程序点击图片全屏

    作为一个只懂简单HTML,jQuery,JS的web后台开发者,最近在学习小程序开发,现在将小程序的点击全屏功能的相关内容记录下来.如果有不对的地方或者有更简单的方法,请留言指教 0_0~ .js 文 ...

  3. Xcode 设置图片全屏显示

    - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typica ...

  4. banner图片全屏显示

    <script> $(function () { function reinitSize() { var window_h = $(window).height(); var window ...

  5. HTML设置body背景图片全屏显示

    在head标签中添加body属性设置: <head><style>body{background:url(timg1.jpg) top left;background-size ...

  6. IOS应用在ios7(iPhone5/iPhone5s)上不能全屏显示

    前言 [IOS应用在iOS7系统或者iPhone5/iPhone5s上不能全屏显示,应用画面上下各有1条黑色,但是在其他系统或者型号的手机上却是正常显示 Paste_Image.png Paste_I ...

  7. 在VC++6.0开发中实现全屏显示

    全屏显示是一些应用软件程序必不可少的功能.比如在用VC++编辑工程源文件或编辑对话框等资源时,选择菜单“View\Full Screen”,即可进入全屏显示状态,按“Esc”键后会退出全屏显示状态. ...

  8. Android开发之全屏显示的两种方法

    1.通过修改清单文件中Theme,实现全屏 <application android:name=".MyApplication" android:allowBackup=&q ...

  9. Xamarin安卓开发:去掉Activity的头部标题栏及全屏显示

    http://blog.csdn.net/u012234115/article/details/35814209 以下是用修改布局文件的方法,其实还有用C#代码的方法. 打开AndroidManife ...

随机推荐

  1. xntp的配置

    ntpdate以一种非常粗暴的方式一次性完成设置时钟.由于实时时钟飘移,你需要周期性的矫正.基本上可以通过设置一个cron例行任务来运行ntpdate,但是你的机器从此就不能是ntp服务器了. 相反, ...

  2. 初识Selenium(三)

    浅谈基于Selenium的Web自动化测试框架 发表于:2011-4-25 10:58  作者:邵育亮   来源:51Testing软件测试网原创 字体:大 中 小 | 上一篇 | 下一篇 | 打印 ...

  3. 11--tag 和transform属性

    tag 和transform属性 1.tag 标签,就相当于身份识别的标码,可以通过tag值获取对应的对象. 2.使用transform 实现对象的平移和旋转. // // ViewControlle ...

  4. android ApplicationContext Context Activity 内存的一些学习

    Android中context可以作很多操作,但是最主要的功能是加载和访问资源. 在android中有两种context,一种是application context,一种是activity cont ...

  5. Codeforces Round #363 (Div. 2) C. Vacations(DP)

    C. Vacations time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  6. Elkstack2.0部署

    部署步骤如下: 1.1 资源拷贝 1 jdk1.8 2 kafka 3 kafka-manager 1.2 jvm 配置 vim /etc/profile.d/java.sh JAVA_HOME=/u ...

  7. SD卡读写扇区注意事项(转)

    源:http://blog.163.com/zhaojun_xf/blog/static/30050580201151410635516/ 在调试SD卡时,大家都喜欢使用扇区进行验证.也就是说,一般都 ...

  8. div定位

    1.float定位带来的问题<html> <head> <title>div浮动引发的问题</title> </head> <styl ...

  9. FZU 2122 又见LKity(KMP+返回所有匹配位置)

    基础kmp应用,找到所有匹配位置即可 #include<stdio.h> #include<string.h> #include<algorithm> #inclu ...

  10. Chapter 1 First Sight——7

    Eventually we made it to Charlie's. 最终我们到了查理斯的家. He still lived in the small,two-bedroom house that ...