Custom UITabBar background image not working in iOS 5 and later

后端 未结 5 2178
不思量自难忘°
不思量自难忘° 2020-12-01 11:13

I have a simple piece of code that places a background image on the tabBar.

UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@         


        
5条回答
  •  执念已碎
    2020-12-01 11:53

    I realize this has been solved, I'm posting this for others who had the same issue as me. I wanted to add a background image to the selected tab in a tabbar. Here is the solution:

    [[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"tabbar.png"]];
    [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabbar-item.png"]];
    

    The second line here adds a background image to the selected tab in a tabbar.

提交回复
热议问题