본문 바로가기
iOS/설명

[iOS] UIView.transition

by Sky Titan 2022. 4. 24.
728x90
 

Apple Developer Documentation

 

developer.apple.com

UIView. transition

  • 특정 container view에 대해서 transition(전환) 애니메이션을 만들 수 있다.
  • removeFromSuperView, addSubview와 같이 특정 뷰에 subview를 추가, 삭제, 보이기, 숨기기 등을 할 때 전환 효과를 줄 수 있다.
class ViewController: UIViewController {
    
    @IBOutlet weak var redView: UIView!
    var blueView: UIView = {
       let view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
        view.backgroundColor = .blue
        return view
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    @IBAction func addClick(_ sender: Any) {
    //blueView를 추가할 때 전환효과
        UIView.transition(with: self.redView, duration: 0.6, options: .transitionFlipFromLeft, animations: {
            self.redView.addSubview(self.blueView)
        })
        
    }
    
    @IBAction func removeClick(_ sender: Any) {
    //blueView를 제거할 때 전환효과
        UIView.transition(with: self.redView, duration: 0.6, options: .transitionFlipFromLeft, animations: {
            self.blueView.removeFromSuperview()
        })
    }
}

 

Option

.transitionFlipFromLeft

.transitionFlipFromLeft

 

.transitionFlipFromRight

.transitionFlipFromRight

 

.transitionFlipFromTop

.transitionFlipFromTop

 

.transitionFlipFromBottom

.transitionFlipFromBottom

 

.transitionCurlUp

. transitionCurlUp

 

.transitionCurlDown

.transitionCurlDown

 

.transitionCrossDissolve

.transitionCrossDissolve

 

728x90

'iOS > 설명' 카테고리의 다른 글

[iOS] UIViewPropertyAnimator  (0) 2022.05.15
[iOS] Push Notification callback함수들  (1) 2022.04.24
[iOS] performBatchUpdates  (0) 2022.04.24
[iOS] json파일 dictionary로 불러오기  (0) 2022.04.22
[iOS] Bundle  (0) 2022.04.22

댓글