Swift development Tutorial--How to define your own Tabbaritem image display

Source: Internet
Author: User

When doing the project, assume that when using the system's Uitabbarcontroller, the bottom tab itself defines the picture to be blue and gray. This is not the effect we want.

Suppose you want to display your own defined, pressed and bouncing picture effects. At this time, the Tabbaritem needs to be changed.

Here is a detailed demo sample:

var itemnamearray:[String] = ["down_32","add_32", "Plane_32" , "Circle_32" ]

var itemnameselectarray:[String] = ["down_click_32","Add_click_32" ,"plane_click_32","circle_click_32"]

func Configtabbar () {

var count:Int =0;

let items =self. TabBar . Items

for item in items as! [uitabbaritem] {

var Image:UIImage =UIImage(named: itemnamearray[count])!

var selectedimage:UIImage =UIImage(named: I Temnameselectarray[count])!;

image = image. Imagewithrenderingmode (uiimagerenderingmode. alwaysoriginal );

selectedimage = selectedimage. Imagewithrenderingmode (uiimagerenderingmode. alwaysoriginal );

Item. SelectedImage = SelectedImage;

Item. Image = image;

count++;

}

}

Swift development Tutorial--How to define your own Tabbaritem image display

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.