iOS/Swift + Objective-c
[Swift] UITabBarController 이미지 설정
안경 쓴 귀니
2022. 8. 29. 21:17
반응형
UITabBarController에서 tabBarItem에 이미지를 적용시킬 경우 아래와 같이 설정한다.
navigationController.tabBarItem.image = UIImage(named: "image.png")
navigationController.tabBarItem.selectedImage = UIImage(named: "selectedImage.png")
위와 같이 진행할 경우, 이미지가 tntColor로 모두 채워지는 문제가 있는데,
그럴 때는 아래와 같이 renderingMode를 alwaysOriginal로 설정해준다.
navigationController.tabBarItem.image = UIImage(named: "image.png")?.withRenderingMode(.alwaysOriginal)
navigationController.tabBarItem.selectedImage = UIImage(named: "selectedImage.png")?.withRenderingMode(.alwaysOriginal)
반응형