[iOS] Uitabbaritem Change the height and width of the image

Source: Internet
Author: User


I have no title and image only Uitabbaritem. I want to know how I can change the size of the image so it can occupy the entire uitabbaritem.



I looked all over the internet, but I couldn't find anything.



I have tried:


Uistoryboard *storyboard = [Uistoryboard storyboardwithname:@ "Main_storyboard" bundle:nil];
Uitabbarcontroller *tabbarcontroller = [storyBoard instantiateviewcontrollerwithidentifier:@ "tab"];
Uitabbar *tabbar = Tabbarcontroller.tabbar;
Uitabbaritem *tabbaritem1 = [Tabbar.items objectatindex:0];
Uitabbaritem *tabbaritem2 = [Tabbar.items objectatindex:1];
Uitabbaritem *tabbaritem3 = [Tabbar.items objectatindex:2];

Tabbaritem1.imageinsets = Uiedgeinsetsmake (0,-10,-6,-10);


But nothing has changed.









A picture of the largest size of an Apple document in Tabbar is a retina monitor of x 60.



I don't think it is possible to take the whole tabbar without stretching the height of the image. I think the best solution is to use the Imageinset Tabbar image in the center


Tabbaritem1.imageinsets = Uiedgeinsetsmake (6, 0,-6, 0);





Otherwise you can play with this imageinset and stretch the image like in the screenshot


Tabbaritem1.imageinsets = Uiedgeinsetsmake (0,-10,-6,-10);







-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {


Uitabbarcontroller *tabbarcontroller = (Uitabbarcontroller *) Self.window.rootViewController;

Uitabbar *tabbar = Tabbarcontroller.tabbar;
Uitabbaritem *tabbaritem1 = [Tabbar.items objectatindex:0];
Uitabbaritem *tabbaritem2 = [Tabbar.items objectatindex:1];
Uitabbaritem *tabbaritem3 = [Tabbar.items objectatindex:2];

Add image to Tabbaritems

Tabbaritem1.imageinsets = Uiedgeinsetsmake (0,-10,-6,-10);
}


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.