iOS/iOS Swift 개발 일기

iOS swift TabBar image 관련

Developer-Michelle 2022. 10. 5. 22:36

iOS swift TabBar image 관련

 

https://vapor3965.tistory.com/101

 

UITabBarItem 이미지가 원본과 다르게 보이는 현상 해결하기

디자이너 분께서 주신 아래 이미지를 토대로 TabBarController의 TabBarItem에 적용하려고 했다. 문제점 하지만 아래와 같이 동그라미이긴 한데.. 다 채워져있다. 몹시 당황스럽다🙃. Debug View Hierarchy에

vapor3965.tistory.com

 

https://stackoverflow.com/questions/61642009/how-can-i-correctly-size-uitabbarcontroller-icons

 

How can I correctly size UITabBarController icons?

I use UITabBarController. In landscape it is looking fine: In portrait though the images are way too big: The images are within xcassets, 512px squared in size and use single scale. I use

stackoverflow.com

 

tabBarItem.imageInsets = UIEdgeInsets(top: 85, left: 85, bottom: 85, right: 85)

위의 숫자가 커질수록 이미지 크기가 커진다.

 

https://stackoverflow.com/questions/16285205/moving-uitabbaritem-image-down

 

Moving UITabBarItem Image down?

Normally on each tab of a UITabBar you have a small image and a title naming the tab. The image is positioned/centred towards the top of the tab to accommodate the title underneath. My question is:...

stackoverflow.com

 

 

https://stackoverflow.com/questions/68671189/uitabbar-items-title-position-issue

 

UITabBar items title position issue

I cannot solve this issue, related to the position of the title of every single tab bar item in a UITabBar. I tried with this: extension UITabBar { override open var traitCollection:

stackoverflow.com

tabbar title position 이동... 생각보다 안먹힌다.

근데 이거 이동이 무의미해진 이유:  iphone 8 기준으로 봤을 때, title이 더 내려가면 글씨가 잘려버리는 현상이 일어남.

 

if #available(iOS 13, *) {
    let appearance = UITabBarAppearance()
    
    // set padding between tabbar item title and image
    appearance.stackedLayoutAppearance.selected.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: 4)
    appearance.stackedLayoutAppearance.normal.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: 4)
    
    self.tabBar.standardAppearance = appearance
} else {
    // set padding between tabbar item title and image
    UITabBarItem.appearance().titlePositionAdjustment = UIOffset(horizontal: 0, vertical: 4)
}