iPhone是否有办法在从一个视图到另一个视图时设置动画类型?

时间:2011-09-27 22:55:49

标签: iphone

我正在使用presentModalViewController从视图控制器转到视图控制器。现在,当动画从一个视图移动到另一个视图时,动画会上下移动。我可以改为左右吗?我没有在presentModalViewController方法中看到任何设置 泰德

1 个答案:

答案 0 :(得分:1)

在演示模态vc之前尝试这个:

[sampleViewController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
// or..
// [sampleViewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
// or..
// [sampleViewController setModalTransitionStyle:UIModalTransitionStylePartialCurl];

查看UIViewController - Here are the Reference docs

modalTransitionStyle属性

您可以为所有样式制作便利方法(来自Modal View Controller Example):

- (IBAction)showDefault:(id)sender {
    SampleViewController *sampleView = [[[SampleViewController alloc] init] autorelease];
    [self presentModalViewController:sampleView animated:YES];
}
 
- (IBAction)showFlip:(id)sender {
    SampleViewController *sampleView = [[[SampleViewController alloc] init] autorelease];
    [sampleView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
    [self presentModalViewController:sampleView animated:YES];
}
 

- (IBAction)showDissolve:(id)sender {
    SampleViewController *sampleView = [[[SampleViewController alloc] init] autorelease];
    [sampleView setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
    [self presentModalViewController:sampleView animated:YES];
}
 
- (IBAction)showCurl:(id)sender {
    SampleViewController *sampleView = [[[SampleViewController alloc] init] autorelease];
    [sampleView setModalTransitionStyle:UIModalTransitionStylePartialCurl];
    [self presentModalViewController:sampleView animated:YES];
}