iphone - UIImagePickerController ......让它从右边出现

时间:2012-01-14 10:15:11

标签: iphone ios uiimagepickercontroller

我必须提供一个UIImagePickerController,但是当我这样做时,它总是来自自下而上。有没有办法让它从右到左显示?

我试过这个没有成功:

CATransition* transition = [CATransition animation];
transition.duration = 0.35f;
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[self.navigationController.view.layer addAnimation:transition forKey:kCATransition];

[self.navigationController presentModalViewController:picker animated:YES];

感谢

1 个答案:

答案 0 :(得分:2)

我假设您当前正在通过调用presentModalViewController:animated:并将YES作为动画选项来显示选择器。

您可以执行的操作是在没有动画的情况下使用,而是使用您自己的过渡动画覆盖外观。下面的例子将从右边出现:

CATransition *transition = [CATransition animation];
transition.duration = 0.5;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromRight;
[self.view.window.layer addAnimation:transition forKey:nil];

[self presentModalViewController:pickerController animated:NO];

要使用此功能,您需要#import <QuartzCore/QuartzCore.h>并将QuartzCore框架添加到项目中。