我的应用程序正在显示阿拉伯语文本,我希望在其中从左侧推送动画,而不是从 ios 默认提供的右侧推送动画。
我正在使用故事板。我创建了自定义 segue。
我已经浏览了所有选项cocoacontrols但没有找到想要的。
我发现了以下几个选项:
1) CATransition
2) 动画
3) 维护视图控制器数组——这会造成很多混乱
下面的代码给出了完美的效果,但下面显示的黑色补丁是不可接受的-
-(void)perform {
UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationController = (UIViewController*)[self destinationViewController];
CATransition* transition = [CATransition animation];
transition.duration = .25;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
transition.subtype = kCATransitionFromLeft; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom
[sourceViewController.navigationController.view.layer addAnimation:transition
forKey:kCATransition];
[sourceViewController.navigationController pushViewController:destinationController animated:NO];
[destinationController.view setBackgroundColor:[UIColor whiteColor]];
}
下面实现的代码没有黑色补丁 - 但不是所需的动画
-(void)perform {
UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationViewController = (UIViewController*)[self destinationViewController];
[sourceViewController.view addSubview:destinationViewController.view];
[destinationViewController.view setFrame:sourceViewController.view.window.frame];
[destinationViewController.view setTransform:CGAffineTransformMakeScale(0.5,0.5)];
[destinationViewController.view setAlpha:1.0];
[UIView animateWithDuration:0.5
delay:0.0
options:UIViewAnimationCurveEaseOut
animations:^{
[destinationViewController.view setTransform:CGAffineTransformMakeScale(1.0,1.0)];
[destinationViewController.view setAlpha:1.0];
}
completion:^(BOOL finished){
[destinationViewController.view removeFromSuperview];
[sourceViewController.navigationController pushViewController:destinationViewController animated:NO];
}];
}
通过更改上面的代码 -但我没有得到想要的结果
-(void)perform{
UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationViewController = (UIViewController*)[self destinationViewController];
[sourceViewController.view addSubview:destinationViewController.view];
[destinationViewController.view setFrame:sourceViewController.view.window.frame];
[destinationViewController.view setAlpha:1.0];
[UIView animateWithDuration:0.5
delay:0.0
options:UIViewAnimationCurveEaseOut
animations:^{
sourceViewController.view.frame = CGRectMake(sourceViewController.view.frame.size.width*2, 0, sourceViewController.view.frame.size.width, sourceViewController.view.frame.size.height);
}
completion:^(BOOL finished){
[sourceViewController.navigationController pushViewController:destinationViewController animated:NO];
}];
}