在我的主ViewController中我有2个UIView的名为AppointmentView和BookView,我在UIView上点击了UIBut,我需要翻转每个视图。
我添加了下面的代码,但问题是当我点击UIButton它的翻转并进入同一页面(而不是第二个视图)。
请帮帮我
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.bookAppointmentView cache:YES];
[self.view addSubview:self.bookAppointmentView];
[UIView commitAnimations];
更新了代码
- (IBAction)addnewPatient:(id)sender {
self.createNewPatientView.hidden=NO;
self.bookAppointmentView.hidden=YES;
self.createNewPatientView.backgroundColor=[UIColor colorWithRed:254.0/255.0 green:254.0/255 blue:254.0/255 alpha:1];
self.createNewPatientView.layer.cornerRadius=5;
self.createNewPatientView.layer.masksToBounds=YES;
[UIView transitionFromView:self.bookAppointmentView toView:self.createNewPatientView duration:.6 options:(UIViewAnimationOptionTransitionFlipFromLeft | UIViewAnimationOptionShowHideTransitionViews) completion:^(BOOL finished)
{
//completion code goes here
}];
}
- (IBAction)existingPatient:(id)sender {
self.bookAppointmentView.hidden=NO;
self.createNewPatientView.hidden=YES;
[UIView transitionFromView:self.createNewPatientView toView:self.bookAppointmentView duration:.6 options:(UIViewAnimationOptionTransitionFlipFromLeft | UIViewAnimationOptionShowHideTransitionViews) completion:^(BOOL finished)
{
//completion code goes here
}];
}
答案 0 :(得分:1)
您最好使用以下动画块执行此操作:
[UIView transitionFromView:view1 toView:view2 duration:.3 options:(UIViewAnimationOptionTransitionFlipFromLeft | UIViewAnimationOptionShowHideTransitionViews) completion:^(BOOL finished)
{
//completion code goes here
}];
干杯!