<h1><center> SwiftUI View Rendering (3) </center></h1> ###### title: ` ` ###### tags: `๐ป TIL` ###### date: `2023-12-18T10:39:33.284Z` > [color=#724cd1][name=๋ฐ๋ฆญ] > [SwiftUI View Lifecycle - Vadim Bulavin](https://www.vadimbulavin.com/swiftui-view-lifecycle/) > [Thinking in SwiftUI](https://www.objc.io/books/thinking-in-swiftui/) > [The SwiftUI render loop - Rens Breur](https://rensbr.eu/blog/swiftui-render-loop/) > [Exploring SwiftUI 3: View Hierarchies and State Updates - Benedict Quinn](https://blog.scottlogic.com/2020/01/28/Exploring-SwiftUI-3-View-Updates.html) > [Understanding View Rendering Cycle in SwiftUI - azamsharp(YouTube)](https://www.youtube.com/watch?v=imiKAwYTX6s) > [SwiftUIโs relationship to UIKit and AppKit - WWDC by Sundell](https://wwdcbysundell.com/2019/swiftui-relationship-to-uikit-appkit/) > [Advanced Graphics and Animations for iOS Apps - WWDC NOTES by Federico Zanetello](https://www.wwdcnotes.com/notes/wwdc14/419/) > [๋ธ๋ก๊ทธ - Coden](https://velog.io/@ictechgy/SwiftUI%EC%9D%98-View-%EB%A0%8C%EB%8D%94%EB%A7%81%EC%9D%80-%EC%96%B8%EC%A0%9C-%EC%9D%B4%EB%A3%A8%EC%96%B4%EC%A7%80%EB%8A%94%EA%B0%80) ## ๊ฐ์ ์ค๋๋ SwiftUI View Rendering์ ๋ํด ํ์ตํด๋ณด์. ์ด ๊ธ์ ๋ด๊ฐ ๋ค๋ฅธ ์ฌ๋์ด ์ด ๊ธ์ ์ฐธ๊ณ ํด์ ๊ณต๋ถํ๋ค๋ ๊ฒ์ ๊ธฐ๋กํ๊ธฐ ์ํด์ ์์ฑํ๋ค. ## Thinking in SwiftUI View tree์ render tree๋ SwiftUI๊ฐ ์๋ํ๋ ๊ฒ์ ์ดํดํ๊ธฐ ์ํด ๊ฐ์ฅ ๊ธฐ๋ณธ์ ์ผ๋ก ์ค์ํ ๊ฐ๋ ์ด๋ผ๊ณ ํ ์ ์๋ค. ์ฐ๋ฆฌ๊ฐ ์ํ๋ Layout์ ์ป๊ธฐ ์ํด์ ์ฐ๋ฆฌ๋ view tree๊ฐ ์ด๋ค ๊ตฌ์กฐ๋ก ์ด๋ฃจ์ด์ ธ ์๋์ง ์ดํดํ ํ์๊ฐ ์๋ค. SwiftUI์์ State๊ฐ ์ด๋ป๊ฒ ์๋ํ๋์ง ์ดํดํ๊ธฐ ์ํด, ๋ทฐ์ lifetime๊ณผ ์ฐ๋ฆฌ๊ฐ ๋ง๋ view tree๊ฐ ์ด๋ป๊ฒ ๊ด๊ณ๋๋์ง ์ดํดํ๋๊ฒ ์ค์ํ๋ค. lifetime์ ์ดํดํ๋ ๊ฒ์ ๋ฐ์ดํฐ๋ฅผ ์ ์ฌํ๊ฑฐ๋ ํ์ํ ๋ ๋ทฐ๋ฅผ ์ ๋ฐ์ดํธํ๊ธฐ ์ํด SwiftUI์ฝ๋๋ฅผ ํจ์จ์ ์ผ๋ก ์์ฑํ๋ ๊ฒ๋งํผ ์ค์ํ๋ค. ๋ง์ง๋ง์ผ๋ก ์ ๋๋ฉ์ด์ ๊ณผ ์ ํ์๋ view tree์ ๋ํ ์ดํด๊ฐ ํ์ํ๋ค. - view tree์ ๋ํ ์ดํด๊ฐ ์ด๋์๋ ํ์ํจ. ```swift Text("Hello") .padding() .background(Color.blue) ``` view tree๋ก ๋ณด๋ฉด .background ์๋์ padding, Color๊ฐ ์๊ณ , padding ์๋์ Text๊ฐ ์๋ค. ์์ ๋ด์ฉ์ ๋ ์์ธํ ์ค๋ช ํ๋ฉด, background modifier๋ view tree์ root์ ์๋ค. ๊ทธ๋ฆฌ๊ณ ํ์ ๋ทฐ๋ก๋ padding๊ณผ Color๋ทฐ๋ก ๋งจ ์์ ๊ทธ๋ ค์ง๊ฒ ๋๋ค. **NOTE** > background view์ modifier ์์ฒด์๋ ์๋ฌด๊ฒ๋ ๊ทธ๋ฆฌ์ง ์๋๋ค. ์ฌ์ง์ด background modifier๊ฐ view tree์์ ๊ฐ์ฅ ์์์ ๋ทฐ์ด์ง๋ง, ์ค์ ๋ฐฐ๊ฒฝ์(ํ๋์) ์ฌ์ ํ ํ ์คํธ ๋ค์ ๊ทธ๋ ค์ ธ ์๋ค.
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up