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];
        
      
    }
  • 相关阅读:
    构建之法8,9,10章
    作业6
    通过处理器类型获得处理器对象
    面经
    C语言实现字符串替换
    计算机网络整理
    常见面试题
    数据库常见面试题
    redis常见知识整理
    项目总结
  • 原文地址:https://www.cnblogs.com/gcb999/p/3343087.html
Copyright © 2011-2022 走看看