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)