[iOS]使用CYLTabBarController时UITabBarItem实心问题
使用TabBarController时,注意设置image的UIImageRenderingModeAlwaysOriginal
属性,否则只显示图片轮廓(被转换过了),图片不能正常显示
- (NSArray *)tabBarItemsAttributesForTabBar {UIImage *buy_normal_icon = [UIImage imageNamed:@"buy_normal"];
buy_normal_icon = [buy_normal_icon imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
// lottie动画的json文件来自于NorthSea, respect!
CGFloat firstXOffset = -12/2;
NSDictionary *firstTabBarItemsAttributes = @{
CYLTabBarItemTitle : @"首页",
CYLTabBarItemImage : [UIImage imageNamed:@"home_normal"],/* NSString and UIImage are supported*/
CYLTabBarItemSelectedImage : @"home_highlight",/* NSString and UIImage are supported*/
CYLTabBarItemTitlePositionAdjustment: [NSValue valueWithUIOffset:UIOffsetMake(firstXOffset, -2.5)]
};
CGFloat secondXOffset = (-25+2)/2;
NSDictionary *secondTabBarItemsAttributes = @{
CYLTabBarItemTitle : @"拍卖",
CYLTabBarItemImage : buy_normal_icon,
CYLTabBarItemSelectedImage : [UIImage imageNamed:@"buy_highlight"],
CYLTabBarItemTitlePositionAdjustment: [NSValue valueWithUIOffset:UIOffsetMake(secondXOffset, -2.5)],
};
NSDictionary *thirdTabBarItemsAttributes = @{
CYLTabBarItemTitle : @"交易",
CYLTabBarItemImage : [UIImage imageNamed:@"sell_normal"],
CYLTabBarItemSelectedImage : @"sell_highlight",
CYLTabBarItemTitlePositionAdjustment: [NSValue valueWithUIOffset:UIOffsetMake(-secondXOffset, -2.5)],
};
NSDictionary *fourthTabBarItemsAttributes = @{
CYLTabBarItemTitle : @"我的",
CYLTabBarItemImage :[UIImage imageNamed:@"mine_normal"],
CYLTabBarItemSelectedImage : @"mine_highlight",
CYLTabBarItemTitlePositionAdjustment: [NSValue valueWithUIOffset:UIOffsetMake(-firstXOffset, -2.5)]
};
NSArray *tabBarItemsAttributes = @[
firstTabBarItemsAttributes,
secondTabBarItemsAttributes,
thirdTabBarItemsAttributes,
fourthTabBarItemsAttributes
];
return tabBarItemsAttributes;
}
【[iOS]使用CYLTabBarController时UITabBarItem实心问题】
核心代码
UIImage *buy_normal_icon = [UIImage imageNamed:@"buy_normal"];
buy_normal_icon = [buy_normal_icon imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
文章图片
IMG_165C17E1EE30-1.jpeg
推荐阅读
- 由浅入深理解AOP
- 【译】20个更有效地使用谷歌搜索的技巧
- 2020-04-07vue中Axios的封装和API接口的管理
- mybatisplus如何在xml的连表查询中使用queryWrapper
- MybatisPlus|MybatisPlus LambdaQueryWrapper使用int默认值的坑及解决
- MybatisPlus使用queryWrapper如何实现复杂查询
- iOS中的Block
- Linux下面如何查看tomcat已经使用多少线程
- 使用composer自动加载类文件
- android|android studio中ndk的使用