Tabbaritem setbadgevalue Style customization (IOS)

Source: Internet
Author: User

1. Convert the cue point of a custom style to an image

-(uiimage*) Convertviewtoimage: (uiview*) v{    = v.bounds.size;    Uigraphicsbeginimagecontextwithoptions (S, NO, [UIScreen mainscreen].scale);    [V.layer Renderincontext:uigraphicsgetcurrentcontext ()];    UIImage*image = uigraphicsgetimagefromcurrentimagecontext ();    Uigraphicsendimagecontext ();     return image;}

2. Connect the Tabbaritem picture to the image converted above

-(UIImage *) Combine: (uiimage*) leftimage rightimage: (uiimage*) rightimage {cgfloat width= LeftImage.size.width +Ten; CGFloat height=LeftImage.size.height; Cgsize offscreensize=cgsizemake (width, height); Uigraphicsbeginimagecontextwithoptions (Offscreensize, NO,0.0); CGRect rect= CGRectMake (5,0, LeftImage.size.width, leftImage.size.height);        [Leftimage Drawinrect:rect]; Rect.origin.x+ = width/2; [Rightimage drawinrect:cgrectmake (LeftImage.size.width-Ten,0, RightImage.size.width, RightImage.size.height)]; UIImage* Imagez =Uigraphicsgetimagefromcurrentimagecontext ();        Uigraphicsendimagecontext (); returnImagez;}

3. Set the image of the Tabbaritem

        [Xxxx.tabbaritem setfinishedselectedimage:[self combine:[uiimage imagenamed:@ "icon_tabbar_session_ Select"] rightimage:[self Convertviewtoimage:_tipview]] withfinishedunselectedimage:[self combine:[ UIImage imagenamed:@ "icon_tabbar_session"] rightimage:[self convertviewtoimage:_ Tipview]];

Effect:

Tabbaritem setbadgevalue Style customization (IOS)

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.