简体   繁体   English

UITabBar选定的背景图像

[英]UITabBar selected background image

i am setting a background image to the selected item of tab bar. 我将背景图像设置为选项卡栏的所选项目。

在此处输入图片说明

UIImage* tabBarBGImage = [UIImage imageNamed:@"bg_image"];
[tabBar setSelectionIndicatorImage:tabBarBGImage];

But the background image comes outside of tabbar. 但是背景图片在标签栏之外。 How can we set the content mode ? 我们如何设置内容模式?

Some answers on stack overflow suggest image resizing, is that the only solution? 关于堆栈溢出的一些答案建议调整图像大小,这是唯一的解决方案吗?

Try to set clipsToBounds and avoid autoresizing of sub views 尝试设置clipsToBounds并避免自动调整子视图的大小

tabBar.autoresizesSubviews = NO;
tabBar.clipsToBounds = YES;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM