IOS7 Story Edition created Tanbar

Source: Internet
Author: User

in iOS7, the method Setfinishedselectedimage : Withfinishedunselectedimage : Has been deprecated, so if you set Tabbaritem's selectimage and image directly, there will be an issue that does not display the picture, the effect may

This picture is obviously different from the one I first wanted, and the picture of myself

Another selected state is white, it can be seen from the above is not the same, below the specific how to write their own desired effect, effect


don't tell me how to create it. Tabbarviewcontroller Everyone will create, below the detailed settings

Uitabbar *tabbar = Self.tabbar;        Uitabbaritem *tabbaritem1 = [Tabbar.items objectatindex:0];    Uitabbaritem *tabbaritem2 = [Tabbar.items objectatindex:1];    Uitabbaritem *tabbaritem3 = [Tabbar.items objectatindex:2];    Uitabbaritem *tabbaritem4 = [Tabbar.items objectatindex:3];    Uitabbaritem *TABBARITEM5 = [Tabbar.items objectatindex:4];

Create a total of 5Uitabbaritem,and then you start setting up the item's picture.
UIImage *tabbaritem1image = [UIImage imagenamed:@ "11"];    UIImage *imgs1image =[uiimage imagenamed:@ "11s"];    Tabbaritem1.selectedimage = [Tabbaritem1image imagewithrenderingmode:uiimagerenderingmodealwaysoriginal];        Tabbaritem1.image = [Imgs1image imagewithrenderingmode:uiimagerenderingmodealwaysoriginal];    UIImage *tabbaritem2image = [UIImage imagenamed:@ "12"];    UIImage *imgs2image =[uiimage imagenamed:@ "12s"];    Tabbaritem2.selectedimage = [Tabbaritem2image imagewithrenderingmode:uiimagerenderingmodealwaysoriginal];        Tabbaritem2.image = [Imgs2image imagewithrenderingmode:uiimagerenderingmodealwaysoriginal];    UIImage *tabbaritem3image = [UIImage imagenamed:@ "13"];    UIImage *imgs3image =[uiimage imagenamed:@ "13s"];    Tabbaritem3.selectedimage = [Tabbaritem3image imagewithrenderingmode:uiimagerenderingmodealwaysoriginal];        Tabbaritem3.image = [Imgs3image imagewithrenderingmode:uiimagerenderingmodealwaysoriginal]; UIImage *tabbaritem4image = [UIImage imagenamed:@ "14"];    UIImage *imgs4image =[uiimage imagenamed:@ "14s"];    Tabbaritem4.selectedimage = [Tabbaritem4image imagewithrenderingmode:uiimagerenderingmodealwaysoriginal];        Tabbaritem4.image = [Imgs4image imagewithrenderingmode:uiimagerenderingmodealwaysoriginal];    UIImage *tabbaritem5image = [UIImage imagenamed:@ "15"];    UIImage *imgs5image =[uiimage imagenamed:@ "15s"];    Tabbaritem5.selectedimage = [Tabbaritem5image imagewithrenderingmode:uiimagerenderingmodealwaysoriginal]; Tabbaritem5.image = [Imgs5image imagewithrenderingmode:uiimagerenderingmodealwaysoriginal];

The method of setting above is iOS7 later use,coloring (Tint color) is a significant change in the IOS7 interface, and you can set a uiimage to use the Tint Color of the current view when rendering. UIImage added a read-only property: Renderingmode, corresponding to a new method: Imagewithrenderingmode:, It uses the Uiimagerenderingmode enumeration value to set the Renderingmode property of the picture. The enumeration contains the following values:

uiimagerenderingmodeautomatic// adjusts the rendering mode automatically based on the environment in which the picture is used and the drawing context in which it is located.

uiimagerenderingmodealwaysoriginal// always draws the original state of the picture without using Tint Color.

uiimagerenderingmodealwaystemplate,// always draw a picture based on Tint Color , Ignores color information for the picture.


Next change the text of item, the code is as follows

[[Uitabbaritem appearance] Settitletextattributes:@{nsfontattributename: [Uifont fontwithname:@ "HelveticaNeue-Bold "size:10.0f],                                                        nsforegroundcolorattributename: [Uicolor orangecolor]                                                        } forstate:uicontrolstatenormal];// Unchecked    [[Uitabbaritem appearance] Settitletextattributes:@{nsfontattributename: [Uifont fontwithname:@] Helveticaneue-bold "size:10.0f],                                                        nsforegroundcolorattributename: [Uicolor greencolor]                                                        } forState: uicontrolstateselected];//selected


Set the background image and the picture below when the item is selected

After setting the item selected, display the figure below this item?    Tabbar.selectionindicatorimage = [UIImage imagenamed:@ "SELECT_BG"];    Set the background map for Tabbar?    Self.tabBar.backgroundImage = [UIImage imagenamed:@ "SHOW_BG"];


Done!

IOS7 Story Edition created Tanbar

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.