# 오른쪽화면이 왼쪽으로 이동하며 등장 (right to left)
# 왼쪽화면이 오른쪽으로 이동하며 등장 (left to right)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class SegueRightToLeft: UIStoryboardSegue { | |
override func perform() { | |
let src = self.source | |
let dst = self.destination | |
src.view.superview?.insertSubview(dst.view, aboveSubview: src.view) | |
dst.view.transform = CGAffineTransform(translationX: src.view.frame.size.width, y: 0) | |
UIView.animate(withDuration: 0.25, delay: 0.0, options: .curveEaseInOut, | |
animations: { | |
dst.view.transform = CGAffineTransform(translationX: 0, y: 0) | |
}, | |
completion: { finished in | |
src.present(dst, animated: false, completion: nil) | |
}) | |
} | |
} | |
class SegueLeftToRight: UIStoryboardSegue { | |
override func perform() { | |
let src = self.source | |
let dst = self.destination | |
src.view.superview?.insertSubview(dst.view, aboveSubview: src.view) | |
dst.view.transform = CGAffineTransform(translationX: -src.view.frame.size.width, y: 0) | |
UIView.animate(withDuration: 0.25, delay: 0.0, options: UIViewAnimationOptions.curveEaseInOut, animations: { | |
dst.view.transform = CGAffineTransform(translationX: 0, y: 0) | |
}) { (finished) in | |
src.present(dst, animated: false, completion: nil) | |
} | |
} | |
} |
# 적용 : Segument 선택 > Attributes Inspector 탭 >
Kind = Custom 선택, Class = SegueLeftToRight 또는 SegueRightToLeft 선택
끝.
'iOS' 카테고리의 다른 글
[XCode/Swift] UITableView dynamic cell height (0) | 2022.02.18 |
---|---|
[XCode/iOS] macos, swift 용 .gitignore 생성방법 (0) | 2019.04.17 |
[iOS] how to create iOS/swift .gitignore in MacOS terminal(console) (0) | 2019.02.18 |
[swift3] Create Simple Progress Dialog View (ProgressBar, ProgressIndicator, LoadingProgress) (0) | 2017.06.27 |
[swift3] Handler Example (0) | 2017.06.21 |