再会!我在标签栏中放置了一张图片,但它的尺寸错误。帮我解决这个问题。我想填充整个项目。
+ (void)setupTabBarAppearance
{
[[UITabBar appearance] setBarTintColor:[UIColor colorWithRed:30.0f/255.0f green:201.0f/255.0f blue:224.0f/255.0f alpha:1]];
UIImage *image = [[self imageWithColor:[UIColor colorWithRed:255.0f/255.0f green:198.0f/255.0f blue:25.0f/255.0f alpha:1]] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 1, 2) resizingMode:UIImageResizingModeStretch];
[[UITabBar appearance] setSelectionIndicatorImage:image];
}
我解决了这个问题,你需要正确计算图像;
+ (UIImage *)imageWithColor:(UIColor *)color andSize:(CGSize)size
{
CGRect rect = CGRectMake(0, 0, size.width, size.height); // <- Here
// Create a 1 by 1 pixel context
UIGraphicsBeginImageContextWithOptions(rect.size, NO, 0);
[color setFill];
UIRectFill(rect); // Fill it with your color
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)