2023. 4. 25.
๋ฌธ์
Custom TabBar์ NavigationBar ๋ฅผ ๋ง๋ค์ผ์ด ์๊ฒผ๋๋ฐ VC์ ๋ฟ๋๋ถ๋ถ์ ์๊พธ Border? Shadow? ๊ฐ์ ์ค์ด ํ๋ ์๊ธด๋ค.
Hierarchy๋ฅผ ๋ณด๋ ์ต์์ ๊ณ์ธต์ ๊น๋ง ImageView๊ฐ ๋ฌ๋ค.
๊ทธ๋์ ๊ตฌ๊ธ๋ง์ ์ข ํด๋ณด๋ UINavigationBarAppearance
๊ฐ์ฒด์ backgroundImage
ํ๋กํผํฐ์ shadowImage
ํ๋กํผํฐ์ ๋น ์ด๋ฏธ์ง๋ฅผ ๋ฃ์ด์ฃผ๋ฉด ์ํ๋๋๋ก ์์ ๋ณ๊ฒฝํ ์ ์๋ค๋ ๊ธ์ ๋ณด์๋ค.
์๋ ๊ฒ ๋ฃ์ด์ค๋ดค๋๋ฐ ์์ธ์ง ๊ทธ๋๋ก ๊น๋ง ImageView๊ฐ ๋ด๋ค.
ํด๊ฒฐ
์๋ง UIImage()๋ฅผ ๋ฃ์ด๋ ์์๋ณํ๋ ์๊ธฐ ๋๋ฌธ์ด ์๋๊น ์ถ์ด์ UIGraphicsGetImageFromCurrentImageContext
๋ฅผ ์ฌ์ฉํด์ ์ง์ ๋จ์์ด๋ฏธ์ง๋ฅผ ๋ง๋ค๊ธฐ๋ก ํ๋ค.
์ด๋ฏธ์ง ์์ฑ
appearance setting
TabBar์ ๊ฒฝ์ฐ์๋ UINavigationBarAppearance ๊ฐ ์๋, UITabBarAppearance๋ฅผ ์ฌ์ฉํ๋ฉด ๋๊ฐ์ด ์ ์ฉ๋๋ค.