【发布时间】:2012-09-24 04:27:55
【问题描述】:
我有一个imageView,我在里面放了一个按钮。我有两个问题:
- 如何在不丢失功能的情况下正确添加按钮?
- 如何在方法中引用我的
imageView来为视图设置动画?
代码:
- (void)viewDidLoad
{
[super viewDidLoad];
UIImageView *grayFrame = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"expSqrGray.png"]];
[self.view addSubview:grayFrame];
grayFrame.frame = CGRectOffset(grayFrame.frame, 0, 0);
UIButton *testButton = [UIButton buttonWithType:UIButtonTypeCustom];
testButton.frame = CGRectMake(20, 20, 200, 44);
testButton.backgroundColor = [UIColor blackColor];
[testButton setTitle:@"Test" forState:UIControlStateNormal];
[testButton addTarget:self action:@selector(tapped:) forControlEvents:UIControlEventTouchUpInside];
[grayFrame addSubview:testButton];
//[self.view addSubview:testButton];
}
【问题讨论】:
-
你想做什么样的动画?
-
只需将带有按钮的图像从底部移动到一定高度即可。
-
是你想要动画的按钮吗?还是按钮内的图片?
-
我希望图像和按钮都使用相同的动画。图片将作为背景,我还将在其上添加标签。
标签: ios xcode animation uibutton