简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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