首页 > 代码库 > 点击放大图片

点击放大图片

//创建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;
}];

点击放大图片