私はアニメーションの順序はImageViewをカスタムSegueに含めるには?
第一のUIViewControllerをどこに行くか、カスタムセグエを作成しようとしてる - > ImageViewの - >第二のUIViewController
私が作品を持っているコードが、何らかの理由でImageViewのは黒です。私は様々なイメージと文字イメージソースを使ってみましたが、まだ黒です。
ここ
1 understanding-よりよいのためのいくつかの写真(最初のUIViewControllerはImageViewのに置き換えられたよう)
2(ImageViewのであるためです2番目のUIViewControllerに置き換えられます)
/**
This segue transitions by dragging the destination UIViewController in from the right and replacing the old UIViewController by pushing it off to the left. This Segue also contains an ImageView that is between the two UIViewControllers.
*/
class CustomSegue2: UIStoryboardSegue {
override func perform() {
// Assign the source and destination views to local variables.
let firstView = self.source.view as UIView!
let secondView = UIImageView()
let thirdView = self.destination.view as UIView!
// Get the screen width and height.
let width = UIScreen.main.bounds.size.width
let height = UIScreen.main.bounds.size.height
// Set properties of secondView
secondView.frame = CGRect(x: width, y: 0, width: width, height: height)
secondView.contentMode = UIViewContentMode.scaleToFill
secondView.image = #imageLiteral(resourceName: "orangeRedGradient_MESH_tealGreenGradient")
// Specify the initial position of the destination view.
let rect = CGRect(x: width + width, y: 0.0, width: width, height: height)
thirdView?.frame = rect
// Access the app's key window and insert the destination view above the current
let window = UIApplication.shared.keyWindow
window?.insertSubview(thirdView!, aboveSubview: firstView!)
// Animation the transition.
UIView.animate(withDuration: 10, animations: {() -> Void in
firstView?.frame = firstView!.frame.offsetBy(dx: -width-width, dy: 0.0)
secondView.frame = secondView.frame.offsetBy(dx: -width-width, dy: 0.0)
thirdView?.frame = thirdView!.frame.offsetBy(dx: -width-width, dy: 0.0)
}) { (Finished) -> Void in
self.source.present(self.destination, animated: false, completion: nil)
}
}
}
これはかなり標準的なセグですか?これで、準備する(forSegue:送信者:)*と* performSegue(withIdentifier:Sender:)*について話しています。もしそうなら、そのコードを投稿してください。ありがとう。 – dfd