ios - How to customize my UITabBar. White icons on gradient background -
ios 7.0. need create design uitabbar. image (this link) shows how looks , how should look. difference that: 1) images on buttons of dirty color, , should white 2) selected item highlighted in little darker background color. not highlighted @ all.
here's how define design in appdelegate.m in application:didfinishlaunchingwithoptions
class="lang-c prettyprint-override"> // background image tabbar uiimage *backgrounddownimage = [uiimage imagenamed:@"background_320_49.png"]; // mode uiimageresizingmodestretch backgrounddownimage = [backgrounddownimage resizableimagewithcapinsets:uiedgeinsetszero resizingmode:uiimageresizingmodestretch]; // set background image uitabbar in application [[uitabbar appearance] setbackgroundimage:backgrounddownimage]; // white color tabbar buttons [[uitabbar appearance] settintcolor:[uicolor whitecolor]]; // special font uitabbaritem [[uitabbaritem appearance] settitletextattributes:[nsdictionary dictionarywithobjectsandkeys:[uifont fontwithname:@"xnjslkpqqovrwqxfnmropbgqtzp" size:0], uitextattributefont, nil] forstate:uicontrolstatenormal];
i tried 4 variants:
1) in method - (id)initwithnibname old code setfinishedselectedimage + withfinishedunselectedimage 2) in method - (id)initwithnibname new code setimage + setselectedimage 3) in method - (void)viewdidload old code 4) in method - (void)viewdidload new code
class="lang-c prettyprint-override">- (void)viewdidload { [super viewdidload]; // variant 1 [self.tabbaritem setimage:[[uiimage imagenamed:@"live.png"] imagewithrenderingmode: uiimagerenderingmodealwaysoriginal]]; [self.tabbaritem setselectedimage:[[uiimage imagenamed:@"live.png"] imagewithrenderingmode: uiimagerenderingmodealwaysoriginal]]; // variant 2 //[self.tabbaritem setfinishedselectedimage:[uiimage imagenamed:@"live.png"] withfinishedunselectedimage:[uiimage imagenamed:@"live.png"]]; [commonuse showlivevideofromcontroller:self]; }
in cases, icons displayed. method initwithnibname (options 1 , 2) no action @ on color icon has not. method viewdidload work both old , new code - in unusual way. when first run application, first icon white, , other gray. if click on other icon , go first, icon becomes white (but picture! text still gray). turns out color of icons affects method viewdidload not exclusively - else missing.
maybe draw 2 sets of icons selected , noselected. in icon , image , text description graphic. still remain 2 points: 1) when first start application, icons gray, , first white. 2) when alter width of screen, not disperse if buttons.
- (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { [self.tabbaritem setfinishedselectedimage:[uiimage imagenamed:@"partners_hover.png"] withfinishedunselectedimage:[uiimage imagenamed:@"partners_small.png"]]; } homecoming self; }
ios objective-c customization uitabbar uitabbaritem
No comments:
Post a Comment