最近我正在做一些像翻转卡的项目。我在视图控制器内有两个子视图,我想在点击按钮时翻转子视图。我现在能做到的,是整个视图翻转,但我只是想子视图ONLY =(请让我知道什么是错我的代码......(感谢球员UIView翻转过渡不起作用
- (void)test: (id)sender{
[UIView transitionFromView:firstView
toView:secondView
duration:0.5f
options:UIViewAnimationOptionTransitionFlipFromRight
completion:^(BOOL finished){
/* do something on animation completion */
}];
}
- (void)viewDidLoad
{
[super viewDidLoad];
firstView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 250, 250)];
secondView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 250, 250)];
firstView.backgroundColor = [UIColor redColor];
secondView.backgroundColor = [UIColor blueColor];
UIButton* button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(0, 0, 25, 25);
[button addTarget:self action:@selector(test:)forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
[self.view addSubview:secondView];
[self.view addSubview:firstView];
}
非常感谢。但是,你能否解释一下为什么我们需要一个容器? – HebitzLau
@ HebitzLau,我希望我可以 - 看来它应该在方法读取方式中没有一个工作。 – rdelmar