zoukankan      html  css  js  c++  java
  • UIImageView 点击放大缩小

    static CGRect oldframe;

    -(void)showImage:(UIImageView *)avatarImageView{

        UIImage *image=avatarImageView.image;

        UIWindow *window=[UIApplication sharedApplication].keyWindow;

        UIView *backgroundView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)];

        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,([UIScreen mainScreen].bounds.size.height-image.size.height*[UIScreen mainScreen].bounds.size.width/image.size.width)/2, [UIScreen mainScreen].bounds.size.width, image.size.height*[UIScreen mainScreen].bounds.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];

        }];

    }

  • 相关阅读:
    atomQQ 笔记 之 好友列表与群列表
    atomQQ 笔记 之 列表元素的异步加载
    android 屏蔽指定activity启动(程序锁)
    Android 创世纪 第三天
    腾讯WebQQ 3.0 密码、验证码加密算法分析
    程序员技术练级攻略
    关于“网上社会实践”网站数据库的设计
    为什么程序员新手要考虑接单?
    关于“网上社会实践”网站的设计
    最近累死人的校园招聘20110928
  • 原文地址:https://www.cnblogs.com/rollrock/p/5416428.html
Copyright © 2011-2022 走看看