2017-09-25 4 views
1

Swift 3でアニメーションのフェードアウト、次にフェードイン、新しいビューコントローラーをプログラムで表示すると、どのビューに応じてポップアップが表示されるのですかユーザが入力するコントローラ。これは、私のアプリがよりモダンで、老いたり、ぼんやりとしているように感じるからです。現在、新しいViewControllerがあります。[Swift 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) 
    } 

で作業をdoesntが、のUIViewController

更新

ここでは、新しい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) 

あなたのアプリをよりモダンにする方法は、それらをコメントので、私はあなたたちを助けることができる

答えて

2
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 }) 

チェックけれども奇妙に見えるコントローラ

+0

を表示するには、アニメーションのために、このコード私はそれがまったく好きではない(PS上記の私のコードで、CollectionViewのセルを実際にクールに表示する関数を確認してください。 –

+0

ok私のコードは、画面中央からポップアップ(実際には小さなサイズからセットサイズまで)のUIViewを頻繁に表示します。これを使用して他のもののデータを表示しますが、UIViewControllersだけでは機能しませんUIView –

+0

涼しい病気だと聞こえるが、それを遅くする方法はありますか? –

関連する問題