[UIKit] ํํ๋ชจ๋ฌ ๊ตฌํ(Scrollable Bottom Sheet) - SheetPresentationController
์ฝ๋๋ฅผ ์คํํ๋ฉด ์ผ์ชฝ์ ๊ฒ์์ ํ๋ฉด ์ฒ๋ผ ๋ฌ๋ค.
์ ๋ชจ๋ฌ์ด ์ ๋จ๊ณ ๋ฒํผ์ด ๋จ๋์ง ์๋ฌธ์ด์๋ค.
๋ฐฐ๊ฒฝ์ ํ์ดํธ๋ก ์ค์ ํด๋๊ณ ๋ณด๋ ๋ชจ๋ฌ์ ์ฌ๋ผ ์์ผ๋
๋ฐฐ๊ฒฝ์ด ๊ฒ์์์ด์ด์ ๋ฒํผ๋ง ์ฌ๋ผ์จ ๊ฒ์ฒ๋ผ ๋ณด์๋ค.
๊ทธ๋ฆฌ๊ณ ์ฌ๊ธฐ์์ ๋ฌธ์ ๋ ๋ด๊ฐ vc๋ฅผ ํ์ฌ์ ViewController๋ก ์ค์ ํด์ ๊ทธ๋ฐ ๊ฒ!
ํด๊ฒฐ์ ํ๊ธฐ์ํด์๋ ๋ชจ๋ฌ์ ๋์ด์ค ์๋ก์ด UIViewController ํ์ผ์ ์์ฑํด์ค์ผ ํ๋ค.
Cocoa Touch Class ํ์ผ๋ก ๋ง๋ค์ด์ค๋ค.
Subclass of : ๋ถ๋ถ์ UIViewController๋ฅผ ์์ํ ํด๋์ค๋ก ์ค์ ํด์ค๋ค.
import UIKit
//ModalController.swift
class ModalController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .yellow
}
}
//ViewController.swift
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .white
let ordeListButton = UIButton()
ordeListButton.setTitle("Show Alert Button", for: .normal)
ordeListButton.setTitleColor(.white, for: .normal)
ordeListButton.backgroundColor = .blue
ordeListButton.frame = CGRect(x: 100, y: 100, width: 200, height: 50)
self.view.addSubview(ordeListButton)
ordeListButton.addTarget(self, action: #selector(ShowOderList), for: .touchDown)
}
@objc
func ShowOderList(){
//์ ํํ๊ณ ์ถ์ ํ๋ฉด์ viewController ์ด๋ฆ
let vc = ModalController()
if let orderSheet = vc.sheetPresentationController {
orderSheet.detents = [.medium()]
}
self.present(vc, animated: true)
}
}
์ ๋๋ก ๋จ๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.
[iOS] Lottie ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ค์น๋ฐฉ๋ฒ - ๋ฐ์น์คํฌ๋ฆฐ ๋ง๋ค๊ธฐ_์ฝ๋๋ฒ ์ด์ค (0) | 2024.07.05 |
---|---|
[UIKit] UITableView ์ฝ๋๋ฒ ์ด์ค ์ฌ์ฉ๋ฒ (0) | 2024.07.04 |
[ UIKit ] addTarget(_:action:for:) ๋ฉ์๋ (0) | 2024.06.30 |
ํท๊ฐ๋ฆฌ๋ UIKit ์์ฑ๊ณผ SnapKit ์ ์ฝ ์์ฑ (0) | 2024.06.27 |
์คํ ๋ฆฌ๋ณด๋๋ก UIScrollView ๋ง๋ค๊ธฐ (0) | 2024.06.22 |