티스토리 뷰
728x90
반응형
UIView transition animation options
먼저 개발자문서를 살펴보자
transition(with:duration:options:animations:completion:)
- 특정 container 뷰의 transition animation 을 만드는 함수이다.
animation 효과를 주기 위해서 파라미터 options 에 해당하는 UIView.AnimationOptions
옵션을 설정해주면 된다.
준비
- Main.storyboard
![](https://user-images.githubusercontent.com/69136340/130177903-9132cd8e-1533-48d0-a838-48d2509b8e60.png)
- 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 형태에 직접적인 옵션들을 실습해보았다.
![](https://user-images.githubusercontent.com/69136340/130177363-8bd4c50c-41e2-47e8-a3ec-5c63f2dd7a08.gif)
![](https://user-images.githubusercontent.com/69136340/130177368-3e779e27-ce9c-48ba-8cc6-e91b9f4180e7.gif)
![](https://user-images.githubusercontent.com/69136340/130177370-c425beea-0a9b-41c4-84db-36fba0fadd6e.gif)
![](https://user-images.githubusercontent.com/69136340/130177451-7bc98464-7404-4f41-b396-5d99983e4423.gif)
![](https://user-images.githubusercontent.com/69136340/130177490-2215b1c7-1e85-48a2-94db-14361e3eeb79.gif)
![](https://user-images.githubusercontent.com/69136340/130177508-d14058bc-5d4a-4113-8df0-7be61bcfb51d.gif)
![](https://user-images.githubusercontent.com/69136340/130177539-547c8875-094f-41d8-b215-ef9d9e561310.gif)
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
- github
- configurable widget
- Swift
- urlsession
- Protocol
- async/await
- RxCocoa
- APNS
- MVVM
- OpenSourceLibrary
- watchOS
- projectsetting
- CloneCoding
- WWDC22
- WidgetKit
- IOS
- MOYA
- Widget
- UserDefaults
- SwiftUI
- 2022 KAKAO TECH INTERNSHIP
- WWDC
- Notification
- Objective-C
- 서버통신
- rxswift
- Firebase
- YPImagePicker
- containerBackground
- Algorithm
최근에 올라온 글
최근에 달린 댓글
글 보관함
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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