티스토리 뷰
728x90
반응형
UIView transition animation options
먼저 개발자문서를 살펴보자
transition(with:duration:options:animations:completion:)
- 특정 container 뷰의 transition animation 을 만드는 함수이다.
animation 효과를 주기 위해서 파라미터 options 에 해당하는 UIView.AnimationOptions
옵션을 설정해주면 된다.
준비
- Main.storyboard

- ViewController.swift
import UIKit
class ViewController: UIViewController {
private var isInitialImage = true
@IBOutlet weak var initialImageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
initialImageView.image = UIImage(named: "initialImg")
initialImageView.contentMode = .scaleAspectFill
}
@IBAction func touchTransitionButton(_ sender: Any) {
print("transitionButton touched.")
// ✅ 앞면의 경우
if isInitialImage {
self.isInitialImage = false
initialImageView.image = UIImage(named: "transitionImg")
// ✅ options 파라미터에 원하는 효과에 해당하는 옵션을 넣어주며 된다.
UIView.transition(with: initialImageView, duration: 1, options:.transitionFlipFromLeft, animations: nil, completion: nil)
}
// ✅ 뒷면의 경우
else {
self.isInitialImage = true
initialImageView.image = UIImage(named: "initialImg")
UIView.transition(with: initialImageView, duration: 1, options: .transitionFlipFromLeft, animations: nil, completion: nil)
}
}
}
UIView.AnimationOptions constants.
transition animation 형태에 직접적인 옵션들을 실습해보았다.







728x90
반응형
'iOS' 카테고리의 다른 글
iOS) 원하는 모서리만 cornerRadius 사용하기 (0) | 2021.08.31 |
---|---|
iOS) Notification.Name extention 해서 사용하기 (0) | 2021.08.23 |
iOS) 애플리케이션의 Life Cycle (0) | 2021.08.17 |
iOS) Modal 의 Life Cycle (0) | 2021.08.14 |
iOS) 원하는 영역에서만 QR코드 읽기 (0) | 2021.08.13 |
댓글
TAG
- 서버통신
- async/await
- WWDC22
- projectsetting
- github
- watchOS
- urlsession
- RxCocoa
- Objective-C
- Protocol
- WidgetKit
- OpenSourceLibrary
- rxswift
- IOS
- SwiftUI
- CloneCoding
- containerBackground
- UserDefaults
- Firebase
- WWDC
- YPImagePicker
- MOYA
- Swift
- Algorithm
- Notification
- MVVM
- 2022 KAKAO TECH INTERNSHIP
- APNS
- Widget
- configurable widget
최근에 올라온 글
최근에 달린 댓글
글 보관함
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
링크
- Total
- Today
- Yesterday