UIWindow

Lenaยท2021๋…„ 7์›” 13์ผ
1

ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒˆ๋กœ ์ƒ์„ฑํ•˜๋ฉด SceneDelegate ์•ˆ์— window ํ”„๋กœํผํ‹ฐ๊ฐ€ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„ ์–ธ๋˜์–ด ์žˆ๋‹ค.

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window: UIWindow?
    
}

UIWindow ๊ฐ์ฒด๋Š” UIView๋ฅผ ์ƒ์†ํ•˜๋Š”๋ฐ, ๊ณต์‹ ๋ฌธ์„œ์—์„œ๋Š” ๋‹ค์Œ ๋‘ ๊ฐ€์ง€ ์ƒํ™ฉ์—์„œ๋งŒ windows ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค๊ณ  ์„ค๋ช…ํ•˜๊ณ  ์žˆ๋‹ค.

@MainActor class UIWindow : UIView
  • app์˜ ์ปจํ…์ธ ๋ฅผ ํ‘œ์‹œํ•˜๊ธฐ ์œ„ํ•ด mian window๋ฅผ ์ œ๊ณตํ•ด์•ผ ํ•˜๊ฑฐ๋‚˜
  • ์ถ”๊ฐ€์ ์ธ ์ปจํ…์ธ ๋ฅผ ํ‘œ์‹œํ•˜๊ธฐ ์œ„ํ•ด ์ถ”๊ฐ€ window๋ฅผ ์ƒ์„ฑํ•ด์•ผ ํ•  ๋•Œ

You use windows only when you need to do the following:
Provide a main window to display your appโ€™s content.
Create additional windows (as needed) to display additional content.

app์˜ ์ปจํ…์ธ ๋ฅผ ํ‘œ์‹œํ•˜๊ธฐ ์œ„ํ•œ mian window๋Š” Xcode ํ…œํ”Œ๋ฆฟ์ด ์Šคํ† ๋ฆฌ๋ณด๋“œ๋ฅผ ์ด์šฉํ•ด ์ž๋™์œผ๋กœ ์ œ๊ณตํ•ด์ฃผ๊ณ  ์žˆ๋‹ค. ๋”ฐ๋ผ์„œ, Main ์Šคํ† ๋ฆฌ๋ณด๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๋Š”๋‹ค๋ฉด ์ง์ ‘ window ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•ด์•ผ ํ•œ๋‹ค.

๊ทธ ์™ธ์— iOS 13๋ถ€ํ„ฐ ์ง€์›ํ•˜๋Š” ๋ฉ€ํ‹ฐ ์œˆ๋„์šฐ๋ฅผ ๊ตฌํ˜„ํ•˜๋ ค๋ฉด window ๊ฐ์ฒด๋ฅผ ์ถ”๊ฐ€๋กœ ์ƒ์„ฑํ•ด์•ผ ํ•œ๋‹ค.
๋ฉ€ํ‹ฐ ์œˆ๋„์šฐ๋Š” ์ฃผ๋กœ ๋˜ ๋”ฐ๋ฅธ ์Šคํฌ๋ฆฐ์— ์ปจํ…์ธ ๋ฅผ ํ‘œ์‹œํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋œ๋‹ค.
(extra windows are commonly used to display content on an external screen, as described in Displaying Content on a Connected Screen.)

UIWindow ๊ฐ์ฒด๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ž‘์—…์„ ํ•  ๋•Œ ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ๋‹ค.

  • window์˜ z์ถ•์„ ์„ค์ •ํ•ด์„œ ๋‹ค๋ฅธ ์œˆ๋„์šฐ๋“ค ์‚ฌ์ด์—์„œ ๋ณด์ด๊ธฐ(visibility)๋ฅผ ์กฐ์ •ํ•  ๋•Œ
  • window๋ฅผ ํ‘œ์‹œํ•ด์„œ ํ‚ค๋ณด๋“œ์˜ ํƒ€๊ฒŸ์ด ๋˜๋„๋ก ํ•  ๋•Œ
  • window ์ขŒํ‘œ๋ฅผ ๋ฐ”๊พธ๊ฑฐ๋‚˜, window์˜ ์ขŒํ‘œ๊ณ„๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋‹ค๋ฅธ ์ขŒํ‘œ๋ฅผ ์„ค์ •ํ•  ๋•Œ
  • window์˜ root view controller๋ฅผ ๋ณ€๊ฒฝํ•  ๋•Œ
  • window๊ฐ€ ํ‘œ์‹œ๋˜๊ณ  ์žˆ๋Š” ์Šคํฌ๋ฆฐ์€ ๋ณ€๊ฒฝํ•  ๋•Œ
  • Setting the z-axis level of your window, which affects the visibility of the window relative to other windows.
  • Showing windows and making them the target of keyboard events.
  • Converting coordinate values to and from the windowโ€™s coordinate system.
  • Changing the root view controller of a window.
  • Changing the screen on which the window is displayed.

ํ•œ ์ค„ ์š”์•ฝ.๐Ÿ˜‰
UIWindow๋Š” UIView๋ฅผ ์ƒ์†๋ฐ›๋Š” app์˜ ์ปจํ…Œ์ด๋„ˆ ๋ทฐ๋กœ,
app์˜ ์ปจํ…์ธ ๋ฅผ ํ‘œ์‹œํ•˜๊ฑฐ๋‚˜ ์—ฐ๊ฒฐ๋œ ๋‹ค๋ฅธ ์Šคํฌ๋ฆฐ์— ํ‘œ์‹œํ•˜๊ธฐ ์œ„ํ•œ ์ถ”๊ฐ€ window๊ฐ€ ํ•„์š”ํ•  ๋•Œ ์‚ฌ์šฉ๋œ๋‹ค.

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