@implementation ViewControl
- (IBAction)bigImage
{
// 1. 添加蒙板(遮罩)
UIButton *cover = [[UIButton alloc] initWithFrame:self.view.bounds];
cover.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.5];
[self.view addSubview:cover];
cover.alpha = 0.0;
[cover addTarget:self action:@selector(smallImage:) forControlEvents:UIControlEventTouchUpInside];
// 2. 将图像按钮弄到最前面
// bringSubviewToFront将子视图前置
[self.view bringSubviewToFront:self.iconButton];
// 3. 动画放大图像按钮
CGFloat w = self.view.bounds.size.width;
CGFloat h = w;
CGFloat y = (self.view.bounds.size.height - h) * 0.5;
[UIView animateWithDuration:1.0f animations:^{
self.iconButton.frame = CGRectMake(0, y, w, h);
cover.alpha = 1.0;
}];
}
/**
* 小图
*/
- (void)smallImage:(UIButton *)changButton
{
// 动画一但定义,马上开始
[UIView animateWithDuration:1.0 animations:^{
// 将图像恢复初始位置
self.iconButton.frame = CGRectMake(85, 85, 150, 150);
changButton.alpha = 0.0;
} completion:^(BOOL finished) {
// 动画完成之后删除cover
[changButton removeFromSuperview];
}];
}
@end
以上,是使用了什么方法?求解,不要笑。。。自学有点费。。。。。。。 |
|