UITabbar (similar to Sina Weibo Demo)

Source: Internet
Author: User

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.