๐Ÿฅ› Layout: iOS_Storyboard @Rising Camp1

Terry/์ด์€ํ•œยท2023๋…„ 1์›” 24์ผ
1

โญ๏ธ RisingCamp

๋ชฉ๋ก ๋ณด๊ธฐ
1/4

๋ณธ ๋‚ด์šฉ์€ ํ•™์Šต์„ ๋ชฉ์ ์œผ๋กœ ์ •๋ฆฌ ๋œ ๋‚ด์šฉ์œผ๋กœ ์ผ๋ถ€ ํ‹€๋ฆฐ ๋‚ด์šฉ์ด ์žˆ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค ๐Ÿ™๐Ÿป

์ •์˜

iphone or ipad ๋“ฑ target์œผ๋กœ ํ•˜๋Š” ๊ธฐ๊ธฐ ๋””์Šคํ”Œ๋ ˆ์ด์— ๊ตฌํ˜„์‹œํ‚ฌ ํ™”๋ฉด.

Safe area: ํ™”๋ฉด์— ์ผ์ • ์—ฌ๋ฐฑ์„ ๋‘์–ด ๋‚ด์šฉ์ด ๊นจ์ง€๋Š” ๊ฒƒ์„ ๋ฐฉ์ง€
Margin: ์ผ์ • ํฌ๊ธฐ์˜ ์—ฌ๋ฐฑ

AutoLayout

Layout์˜ Margin์„ ํŽธํ•˜๊ฒŒ ์ง€์ •ํ•ด์ฃผ๋Š” ๊ธฐ๋Šฅ
Xcode๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ Layout์„ ๊ตฌ์„ฑ ํ•  ๋•Œ์— Margin์„ ์ง€์ •ํ•˜๋Š” ์—ฌ๋Ÿฌ ๋ฐฉ๋ฒ•์ด ์žˆ๋Š”๋ฐ,
iphone์˜ ์ข…๋ฅ˜ ํ˜น์€ ipad์˜ ์ข…๋ฅ˜๊ฐ€ ๋ฐ”๋€Œ์–ด๋„ ์ผ์ • Margin์„ ์œ ์ง€ํ•œ ์ƒํƒœ๋กœ ๋งŒ๋“ค์–ด์ฃผ๊ธฐ์— ํ•„์ˆ˜๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ธฐ๋Šฅ์ด๋ผํ•ด๋„ ๊ณผ์–ธ์ด ์•„๋‹ˆ๋‹ค.

Code๋กœ AutoLayout ์„ค์ •

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

profile
iOS ๊ฐœ๋ฐœ์ž

0๊ฐœ์˜ ๋Œ“๊ธ€