편집 : IT는 모든이 솔루션이 작동해야 후, 나는
UIImage *selTab = [[UIImage imageNamed:@"tabHighlight"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
CGSize tabSize = CGSizeMake(CGRectGetWidth(self.view.frame)/5, 49);
UIGraphicsBeginImageContext(tabSize);
[selTab drawInRect:CGRectMake(0, 0, tabSize.width, tabSize.height)];
UIImage *reSizeImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//
[self.tabBar setSelectionIndicatorImage:reSizeImage];
tabHiglight
는 82x49의 PNG입니다 캐시 몇 가지 문제가 있었다 것 같다, 내가 테스트 한 다른 크기지만 이것이 가장 잘 맞는 것 같습니다. 프레임의 width
을 tabBar에있는 항목의 수로 나눕니다. 제 경우 5에서 "올바른 크기"의 새 UIImage를 만들고 selectionIndicatorImage
으로 설정합니다.
I 사용 배 및 3 배 장치를 지원하기 위해 : UIGraphicsBeginImageContextWithOptions (tabSize를 NO [UIScreen mainScreen] .scale); – AlexD