如何使用Swift在iOS中从右到左显示视图控制器

我正在使用presentViewController呈现新屏幕

let dashboardWorkout = DashboardWorkoutViewController()

presentViewController(dashboardWorkout, animated: true, completion: nil)

这将显示从下到上的新屏幕,但我希望不使用即可从右到左显示UINavigationController

我使用的是Xib而不是情节提要,该怎么办?

回答:

是否使用xibstoryboard正在使用都没有关系。通常,当您将视图控制器推入Presentor时,使用从右向左过渡UINavigiationController

新增计时功能 kCAMediaTimingFunctionEaseInEaseOut

示例项目与

实现加入GitHub上

let transition = CATransition()

transition.duration = 0.5

transition.type = CATransitionType.push

transition.subtype = CATransitionSubtype.fromRight

transition.timingFunction = CAMediaTimingFunction(name:CAMediaTimingFunctionName.easeInEaseOut)

view.window!.layer.add(transition, forKey: kCATransition)

present(dashboardWorkout, animated: false, completion: nil)

CATransition *transition = [[CATransition alloc] init];

transition.duration = 0.5;

transition.type = kCATransitionPush;

transition.subtype = kCATransitionFromRight;

[transition setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

[self.view.window.layer addAnimation:transition forKey:kCATransition];

[self presentViewController:dashboardWorkout animated:false completion:nil];

let transition = CATransition()

transition.duration = 0.5

transition.type = kCATransitionPush

transition.subtype = kCATransitionFromRight

transition.timingFunction = CAMediaTimingFunction(name:kCAMediaTimingFunctionEaseInEaseOut)

view.window!.layer.addAnimation(transition, forKey: kCATransition)

presentViewController(dashboardWorkout, animated: false, completion: nil)

在自定义转换的情况下,方法中的animated参数presentViewController似乎并不重要。它可以是任何值,true或者false

以上是 如何使用Swift在iOS中从右到左显示视图控制器 的全部内容, 来源链接: utcz.com/qa/409143.html

回到顶部