Swift-Let the tab bar button uitabbaritem the picture centered (no text) _ Use

Source: Internet
Author: User

For the tab bar (Uitabbar), when the Tabbaritem does not need title as long as the image, the image below will occupy a space.
We can set the offset by tabbaritem.imageinsets so that the image icon is centered.
(Note: Top and bottom are set to the opposite number, otherwise the image size will change.) )
1 2 3 4 5 6 7 8 9 (import ) uikit   class  Maintabviewcontro (+) Ller:uitabbarcontroller {     override  func  viewdidload ()      {          super. Viewdidload ()          //altogether contains two views          let  Qqview =  Qqviewcontroller ()         //qqview.title = ""           let  Skypeview =  skypeviewcontroller ()         // Skypeview.title = ""                    //Declaration of two view controllers          let  QQ =  Uinavigationcontroller (Rootviewcontroller:qqview)          qq.tAbbaritem.image =  UIImage (named: "QQ")          Qq.tabBarItem.imageInsets =  Uiedgeinsetsmake (6, 0,-6, 0);                    Let   Skype =  uinavigationcontroller (rootviewcontroller:skypeview)           skype.tabBarItem.image =  uiimage (named: "Skype")           Skype.tabBarItem.imageInsets =  uiedgeinsetsmake (6, 0,-6, 0);                    Self. Viewcontrollers = [Qq,skype]     }}

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.

Tags Index: