2017-02-04 7 views
3

UIView.transitionメソッドを使用して2つのビューを切り替えましたが、その後両方のビューのフレームが変更されました。UIViewのフレームが反転された後に変更されました

if isFront { 
    UIView.transition(from: frontView, to: behindView, duration: 0.5, options: .transitionFlipFromRight,completion: { (finished) in 
     if finished { 
      self.isFront = false 
     } 
    }) 
} else { 
    UIView .transition(from: behindView, to: frontView, duration: 0.5, options: .transitionFlipFromLeft, completion: { (finished) in 
     if finished { 
      self.isFront = true 
     } 
    }) 
} 

私の考えは?あなたのお手伝いをありがとう。

image

答えて

2

私は同じ問題を解決しました。問題は、ビューAからビューBへのフリップトランジションを使用するとき、その制約を失うことです。

対処:

はparentView及び使用中に両方のビュー(すなわちfrontViewとbehindView)を入れ:

UIView.transition(with: scroller, duration: 0.5, options: .transitionFlipFromLeft,animations: {() -> Void in}, completion: { _ in }) 

例:文法と

@IBAction func FlipButtonAction(_ sender: Any) { 
    if(front){    
     frontView.isHidden = true 
     behindView.isHidden = false 

     UIView.transition(with: parentView, duration: 0.5, options: .transitionFlipFromLeft,animations: {() -> Void in}, completion: { _ in }) 

     print("1") 
    }else{ 
     frontView.isHidden = false 
     behindView.isHidden = true 

     UIView.transition(with: parentView, duration: 0.5, options: .transitionFlipFromLeft,animations: {() -> Void in}, completion: { _ in }) 
     print("2") 

    } 
    front = !front 

} 
+0

ありがとうの@maddy :) –

関連する問題