๋ณธ ๋ด์ฉ์ ํ์ต์ ๋ชฉ์ ์ผ๋ก ์ ๋ฆฌ ๋ ๋ด์ฉ์ผ๋ก ์ผ๋ถ ํ๋ฆฐ ๋ด์ฉ์ด ์์ ์ ์์ต๋๋ค ๐๐ป
iphone or ipad ๋ฑ target์ผ๋ก ํ๋ ๊ธฐ๊ธฐ ๋์คํ๋ ์ด์ ๊ตฌํ์ํฌ ํ๋ฉด.
Safe area: ํ๋ฉด์ ์ผ์ ์ฌ๋ฐฑ์ ๋์ด ๋ด์ฉ์ด ๊นจ์ง๋ ๊ฒ์ ๋ฐฉ์ง
Margin: ์ผ์ ํฌ๊ธฐ์ ์ฌ๋ฐฑ
Layout์ Margin์ ํธํ๊ฒ ์ง์ ํด์ฃผ๋ ๊ธฐ๋ฅ
Xcode๋ฅผ ์ฌ์ฉํ์ฌ Layout์ ๊ตฌ์ฑ ํ ๋์ Margin์ ์ง์ ํ๋ ์ฌ๋ฌ ๋ฐฉ๋ฒ์ด ์๋๋ฐ,
iphone์ ์ข
๋ฅ ํน์ ipad์ ์ข
๋ฅ๊ฐ ๋ฐ๋์ด๋ ์ผ์ Margin์ ์ ์งํ ์ํ๋ก ๋ง๋ค์ด์ฃผ๊ธฐ์ ํ์๋ก ์ฌ์ฉํ๋ ๊ธฐ๋ฅ์ด๋ผํด๋ ๊ณผ์ธ์ด ์๋๋ค.
override func viewDidLoad() {
super.viewDidLoad()
let sodeulButton: UIButton = .init(frame: .init())
sodeulButton.backgroundColor = .yellow
sodeulButton.setTitle("๋ฐ๋ฅธ์ํ ์๋ค๋งจ", for: .normal)
//์ฌ๊ธฐ๋ถํฐ๊ฐ autoLayout์ ํ์ํ ์ฝ๋๋ค
self.view.addSubview(sodeulButton)
sodeulButton.translatesAutoresizingMaskIntoConstraints = false
sodeulButton.topAnchor.constraint(equalTo: self.view.topAnchor, constant: 100).isActive = true
sodeulButton.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 100).isActive = true
sodeulButton.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: -80).isActive = true
}
referance
https://developer.apple.com/design/human-interface-guidelines/foundations/layout/
https://babbab2.tistory.com/155?category=932180