提出了新的视图控制器编程[斯威夫特3]
问题描述:
我所试图做的是提出了一种新的视图控制器编程与斯威夫特3动画淡出,然后淡入,然后弹出弹出的下拉取决于什么看法用户输入的控制器。这是因为我的应用程序感觉更现代化,不那么古老和块状。提出了新的视图控制器编程[斯威夫特3]
这里是当前的方法我使用用于呈现新视图控制器。它的工作原理,但它是相当突然和机器人:
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let ExampleVC = storyBoard.instantiateViewController(withIdentifier: "ExampleVC")
//ExampleVC standing for ExampleViewController
self.navigationController?.pushViewController(ExampleVC, animated: false)
这里是动画UIViews的方法,但它不与UIViewControllers工作
func popIn(yourView : UIView) {
yourView.transform = CGAffineTransform(scaleX: 0.01, y: 0.01)
UIView.animateKeyframes(withDuration: 0.2, delay: 0.0, options: UIViewKeyframeAnimationOptions.calculationModeDiscrete, animations: {
yourView.transform = .identity
}, completion: nil)
self.view.addSubview(yourView)
}
我需要类似的东西,这一点,但对于一个UIViewController
UPDATE
这里是你将用来展示一个新的viewcontroller在一个很酷的方法,使您的应用更现代化
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let VC = storyboard.instantiateViewController(withIdentifier: "Example") //<<< make sure you enter in your storyboard ID here or you will crash your app
VC.modalTransitionStyle = .crossDissolve //you can change this to do different animations
VC.view.layer.speed = 0.1 //adjust this to animate at different speeds
self.navigationController?.present(VC, animated: true, completion: nil)
,如果您有任何疑问,意见他们,所以我可以帮你们出
答
var storyboard = UIStoryboard(name: "Main", bundle: nil)
var ivc = storyboard.instantiateViewController(withIdentifier: "ExampleVC")
ivc.modalTransitionStyle = .crossDissolve
ivc.view.layer.speed = 0.1
self.present(ivc, animated: true, completion: { _ in })
检查这个代码的动画,查看控制器
那看起来很奇怪,虽然我根本不喜欢它(PS检查我的代码上面的功能,呈现CollectionView单元格真的很酷像 –
好的我上面的代码提出了一个UIView弹出窗口(它从一个非常小的尺寸扩大到一个设置的大小)风格我经常从屏幕中心使用它来呈现其他东西的数据,但它不适用于UIViewControllers只UIView –
哥们儿听起来很酷生病尝试它,但有什么办法减慢它? –