我正在实现一个在另一个UITabBar中的UITabBar。我的问题是,无论屏幕大小如何,第二个TabBar的宽度都保持不变。这在大屏幕上非常突出。我附上一张截图以让您更好地理解。蓝色背景表示选定状态。
以下是代码:
GRect rect = CGRectMake(0, 0, self.tabBar.frame.size.width/2, self.tabBar.frame.size.height);
UIGraphicsBeginImageContext(rect.size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context,
[[UIColor colorWithRed:102.0/255.0 green:197.0/255.0 blue:234.0/255.0 alpha:1.0] CGColor]);
CGContextFillRect(context, rect);
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
self.tabBar.selectionIndicatorImage = img;
来自iPhone6 Plus的截屏