[IPhone-tabbar] How to customize tabbarcontroller

Source: Internet
Author: User

What is tabbarcontroller?

Tabbar, which is usually used to switch between viewcontrollers. There are several usage methods. The most common one is to specify the tabarray, which stores the controllers object in order as the switch below. This operation can be placed in appdelegate and added to the window.

In-depth understanding of tabbarcontroller

 

I tried tabbarcontroller, and hidden = yes of tabbar. Then I found that the black tabbar is missing, but there will be white things on it. The background color cannot be set to clear. Later, we found that the height of the actual content of tabbar is smaller. So it looks white. Later, the content is extended. Although tabbar is still in the position below, it will not have the white effect after hiding it.

 

If ([[self. View. subviews objectatindex: 0] iskindofclass: [uitabbar class])
Contentview = [self. View. subviews objectatindex: 1];
Else
Contentview = [self. View. subviews objectatindex: 0];

View the content

 

.How to customize tabbarcontroller

 

1. The first method is to completely rewrite tabbarcontroller and use view instead. The buttons above are used, and the workload is very large. One thing is that the switchover between different levels cannot be too thorough. When is it on top, and when is it hidden.

 

2. The second is to inherit a uitabbarcontroller and add a View to the upper layer of this subclass. The advantage of this is that you can switch directly through the tabbar of hide.

 

Intermediate function. -(Void) switchview :( ID) sender

{Int Index = [self. subviews indexofobject: sender];

Tabbarctrl. selectedindex = index;

}

 

Finally, when we need badgevale, don't forget to go to 320 to find useful ones.

 

 

 

 

 

 

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.