黑马程序员技术交流社区
标题:
菜鸟疑问,smallImage方法为什么可以访问(UIButton*)cover
[打印本页]
作者:
bengbeng84
时间:
2015-12-19 21:07
标题:
菜鸟疑问,smallImage方法为什么可以访问(UIButton*)cover
@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
以上,是使用了什么方法?求解,不要笑。。。自学有点费。。。。。。。
作者:
菜鸟一只
时间:
2015-12-19 23:20
因为 [cover addTarget:self action:@selector(smallImage:) forControlEvents:UIControlEventTouchUpInside];
作者:
菜鸟一只
时间:
2015-12-19 23:21
cover注册了一个方法 ,名字就叫做 smallImage:
作者:
注意背后
时间:
2015-12-20 00:25
顶顶新人贴
作者:
iOS-lye
时间:
2015-12-20 01:15
66666666666
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2