zoukankan      html  css  js  c++  java
  • 新浪博客中放大图片的做法

    在自定义cell中子的UIImageview添加手势,单击手势触发下面的事件

     
    UIImageview  _statuImage=[[UIImageView alloc] init];
            _statuImage.userInteractionEnabled=YES;
            [self.contentView addSubview:_statuImage];
            _statuImage.contentMode=UIViewContentModeScaleAspectFit;
            [_statuImage release];
            
    
                UITapGestureRecognizer *tap=[[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(openPic:)] autorelease];
                [_statuImage addGestureRecognizer:tap];
    -(void)openPic:(UITapGestureRecognizer *)tap{
        
        
            [UIView beginAnimations:@"present" context:nil];
            [UIView setAnimationDuration:0.25];
                    
            CGRect r = [[UIApplication sharedApplication] keyWindow].frame;
        
            alphaView = [[UIView alloc] initWithFrame:r];
            alphaView.backgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1];
            alphaView.alpha = 0.95;
           [[[UIApplication sharedApplication] keyWindow] addSubview:alphaView];
           [alphaView release];
        
            UITapGestureRecognizer *closeTap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closePic)];
            [alphaView addGestureRecognizer:closeTap];
            [closeTap release];
    
            EGOImageView *img=[[EGOImageView alloc] initWithFrame:alphaView.bounds];
            [alphaView addSubview:img];
            [img release];
        
            [UIView commitAnimations];
        
           Status *frame=self.cellData.Mystaus;
            if (tap.view==_statuImage) {
                if (frame.originalImageUrl) {
                        [img setImageURL:[NSURL URLWithString:frame.originalImageUrl]];
                }
    
            }
            if (tap.view==_retweetStatusimg) {
                if (frame.retweetedStatus.originalImageUrl) {
                     [img setImageURL:[NSURL URLWithString:frame.retweetedStatus.originalImageUrl]];
                }
    
            }
    
    }
    
    
    -(void)closePic{
      
        [UIView beginAnimations:@"present" context:nil];
        [UIView setAnimationDuration:0.25];
        alphaView.frame = CGRectMake(0, 600, 320, 600);
        [UIView commitAnimations];
        [alphaView removeFromSuperview];
        
      
    }
  • 相关阅读:
    深度剖析Byteart Retail案例
    REVIT使用中遇到的各种问题汇总
    常用设计规范
    编程修养
    Linux、Windows静态编译ffmpeg 4.4.1、x264、x265等编解码库的脚本
    程序员的灯下黑:重知识轻技术
    GitHub 公布 2021 Top 10 博文「GitHub 热点速览」
    狠人!标星 3.4 万的项目说删就删,几行代码搞崩数万个开源项目
    重装系统前备份fstab
    Ubuntu系统下制作U盘启动盘
  • 原文地址:https://www.cnblogs.com/gcb999/p/3343087.html
Copyright © 2011-2022 走看看