UITabBar fully transparent

In Xcode, I use the interface constructor (StoryBoard) to lay out most of my layout. However, I want some custom drawing to be done on it. It works very well.

However, there is a problem that I encountered. I have a "bite" from the active tab. (see http://cl.ly/Efno ) I want this bite to be completely transparent. (I set the background color to pink to see which part I want transparent, which is not transparent.)

How I changed the look and looks as follows.

  • Set the UITabBar class for my own class in the interface builder for the corresponding tab.
  • In the awakeFromNib of this class, I set the position and image of the label and the selected image of each panel element. Thus

    [tabBarItem setFinishedSelectedImage:selectedImage withFinishedUnselectedImage:image]; 

Each image completely covers the entire panel in height and has the width of the tab element itself.

  • Set the background image to the none tab (fully transparent image)
  • Set the background color of the panel to a completely transparent color (now I have a pink color to see where it goes wrong)
  • In the interface builder, clear the “opaque” check box for the tab.

However, it is not transparent, the pink part is black. How can I make it transparent?

thanks

+4
source share
1 answer

Look at the appearance proxy for UITabBar, you can do what you want without using a custom subclass. There are tons of properties you can get and change. You can set the appropriate properties in the application delegate. This is only iOS5, but I understand that you are already using this since you mentioned storyboards.

eg.

 UIImage *tabBarBackground = [UIImage imageNamed:@"tabBarBackground.png"]; [[UITabBar appearance] setBackgroundImage:tabBarBackground]; [[UITabBar appearance] setSelectedImageTintColor:[UIColor colorWithRed:127.0/255.0 green:186.0/255.0 blue:235.0/255.0 alpha:1.0]]; [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabBarItemSelected.png"]]; 
+4
source

Source: https://habr.com/ru/post/1399452/


All Articles