美文网首页
微信图片点击放大效果

微信图片点击放大效果

作者: KeepFighting | 来源:发表于2016-04-11 16:15 被阅读1099次

    1.通过上下文获取当前图片
    2.动态添加一个UIImageView
    3.计算目标位置的frame 做属性动画
    4.动画完毕移除imageVIew,创建对应的图片查看器(未实现)

    UIGraphicsBeginImageContextWithOptions(self.imageView.bounds.size, YES, 0);
        [self.imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
        UIImageView * coverView = [[UIImageView alloc] initWithImage:image];
        coverView.frame = self.imageView.frame;
        [self.view addSubview:coverView];
        CGFloat w = [UIScreen mainScreen].bounds.size.width;
        CGFloat h = w / coverView.bounds.size.width * coverView.bounds.size.height;
         [UIView animateWithDuration:4 animations:^{
             coverView.frame = CGRectMake(([UIScreen mainScreen].bounds.size.width - w) * 0.5, ([UIScreen mainScreen].bounds.size.height - h) * 0.5, w, h);
         } completion:^(BOOL finished) {
             [coverView removeFromSuperview];
         }];
    

    相关文章

      网友评论

          本文标题:微信图片点击放大效果

          本文链接:https://www.haomeiwen.com/subject/wkeilttx.html