最近我正在做一些类似翻转卡的项目。我在视图控制器中有两个子视图,我想通过单击按钮来翻转子视图。我现在可以实现的是整个视图都在翻转,但我只想要子视图=(请让我知道我的代码有什么问题.....;(谢谢大家
- (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];
}