UITabBarItem에서 아이콘의 "선택되지 않음"또는 표시되지 않는 상태를 어떻게 변경합니까?
UITabBarItem.appearance (). setTitleTextAttributes (:) 설정을 시도했지만 텍스트 색상 만 변경됩니다.
어떤 생각?
iOS 7 이상에서 기본값을 변경하려면 실제로 다른 아이콘 (선택하지 않은 탭에 대해 원하는 색상)을 사용하고 텍스트 색상을 설정해야합니다. 두 세트의 아이콘을 만드는 대신이 조정을 적용 할 수 있습니다.
// set the selected colors
[self.tabBar setTintColor:[UIColor whiteColor]];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor whiteColor], NSForegroundColorAttributeName, nil] forState:UIControlStateSelected];
UIColor * unselectedColor = [UIColor colorWithRed:184/255.0f green:224/255.0f blue:242/255.0f alpha:1.0f];
// set color of unselected text
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:unselectedColor, NSForegroundColorAttributeName, nil]
forState:UIControlStateNormal];
// generate a tinted unselected image based on image passed via the storyboard
for(UITabBarItem *item in self.tabBar.items) {
// use the UIImage category code for the imageWithColor: method
item.image = [[item.selectedImage imageWithColor:unselectedColor] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다