UITabbar (similar to Sina Weibo Demo)
UITabBarController and UINavigationController are the navigation modes selected by most apps. UITabBarController's UITabBar is the UI part presented to users. Therefore, it is very important to understand its attributes and how to customize them. This article imitates Sina Weibo to write a simple Tabbar. If you are interested, you can download it and take a look at the Demo implementation. I will briefly mention it at the end of this article.
Demo effect (the icon text is casually written)
Static Graph
Animation
The specific Demo code will not be explained. If you are interested, you can download it and find out what is going on. In addition, my resources can be downloaded without points.
Download link
Http://download.csdn.net/detail/hello_hwc/9068705
Common UITabbar attributes
TintColor // define the optional color of TabBarItems
For example, set it to red
Image-related attributes
backgroundImage
Set the background image of UITabbar. For example, set the background image of the previous Demo to gradient.
ShadowImage // specifies the selectionIndicatorImage of the shadowImage. // you can specify a shadowImage on the tabbar and an image under the baritem.
Translucent // whether transparent
Several common attributes of UIBarItem
Image/selectedImage // image, and the selected image
For example, in my Demo, the intermediate Item is set as follows:
Make sure that the image I want is used for all clicks.
item.image = [midImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; item.selectedImage = [midImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
Adjust the title and Icon positions
titlePositionAdjustment/imageInsets
For example, in my Demo, there is a big image in the middle and there is no title. You need to adjust the Icon position.
item.imageInsets = UIEdgeInsetsMake(5.0, 0, -5.0, 0);
Before Adjustment
After
Set font styles <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4NCjxwcmUgY2xhc3M9 "brush: java;"> setTitleTextAttributes:forState:
For example, use the following code to set the font to blue
[item setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blueColor]} forState:UIControlStateNormal];
Comparison before and after Configuration
I tried the Keyframe, UISnapBehaviour, and the code in the Demo to use the uivisualiztview animation in the Demo. I found it clearer in the Demo. Use tags to pass the icons to be clicked