点击放大图片

//创建button遮挡
UIButton *cover = [[UIButton alloc]initWithFrame:self.view.frame];
[cover setBackgroundColor:[UIColor blackColor]];
cover.alpha = 0;
[self.view addSubview:cover];
[cover addTarget:self action:@selector(smallImg) forControlEvents:UIControlEventTouchUpInside];
self.cover = cover;

//image提前
[self.view bringSubviewToFront:self.iconBtn];
//改变frame
[UIView animateWithDuration:0.25 animations:^{
CGFloat w = self.view.frame.size.width;
CGFloat y = (self.view.frame.size.height - w) * 0.5;
self.iconBtn.frame = CGRectMake(0, y, w, w);
cover.alpha = 0.7;
}];

 

 

- (void)smallImg{

    

    //改frame

    [UIView animateWithDuration:0.25 animations:^{

        self.iconBtn.frame = self.rect;

        self.cover.alpha = 0;

    }];

    //移除cover

    [self.cover removeFromSuperview];

    self.cover = nil;

    

}

你可能感兴趣的:(图片)