0108 点击时 大小图

  1.  

    /**

     *  大图功能

     */

    - (IBAction)big {

    //    1.添加阴影

        UIButton *cover = [[UIButton alloc]init];

        cover.frame = self.view.bounds;

        [self.view addSubview:cover];

        cover.backgroundColor = [UIColor blackColor];

        cover.alpha = 0.0;

        self.cover = cover;

    //     1.1给阴影添加点击事件

        [cover addTarget:self action:@selector(smallImage) forControlEvents:UIControlEventTouchUpInside];

    //     2调整位置

        [self.view bringSubviewToFront:self.head];//head到最前边

    //     3.修改headframe

        [UIView beginAnimations:nil context:nil];

      

        [UIView setAnimationDuration:1.5];

        cover.alpha = 0.6;

        

        CGFloat headW = self.view.frame.size.width;

        CGFloat headH = headW;

        CGFloat headX = 0;

        CGFloat headY = ( self.view.frame.size.height - headH)*0.5;

        self.head.frame = CGRectMake(headX, headY, headW, headH);

        [UIView commitAnimations];

        

        

        

        

    }

     

    /**

     *  小图功能的点击

     */

    - (void)smallImage{

    ////    1.阴影移除

    //    [self.cover removeFromSuperview];

    ////    2.修改头像frame

    //    self.head.frame = CGRectMake(97, 145, 180, 180);

        

        [UIView animateWithDuration:1.5 animations:^{

            self.cover.alpha = 0.0;

            self.head.frame = CGRectMake(97, 145, 180, 180);

        } completion:^(BOOL finished) {

            [self.cover removeFromSuperview];

            self.cover = nil;

        }];

        

        

        

    }

原文地址:https://www.cnblogs.com/gzz2016/p/5113479.html