[Self createcustomtabbar];
-(void) createcustomtabbar{
Create a Uiimageview, as a basemap
Uiimageview *bgview = [[Uiimageview alloc] Initwithframe:cgrectmake (0,[uiscreen mainscreen].bounds.size.height-49, 320, 49)];
Bgview.image = [UIImage imagenamed:@ "Tabbg.png"];
Bgview.tag = 999;
Turn on interactive properties for ImageView
bgview.userinteractionenabled = YES;
[Self.view Addsubview:bgview];
Creating a button instance simulation Tabbaritem
Between each button
Nsarray *array=[nsarray arraywithobjects:@ "iconsettings", @ "Iconprofile", @ "Iconhome", @ "Iconempty", @ "IconCalendar" , @ "Btn_bottom1_on.png", @ "Btn_bottom2_on.png", @ "Btn_bottom3_on.png", @ "Btn_bottom4_on.png", @ "Btn_bottom5_on.png" , nil];
for (int i = 0; i< (array.count)/2; i++) {
NSString *imagename = [array objectatindex:i];
NSString *selectedimage = [array objectatindex:i+5];
UIButton *btn = [UIButton buttonwithtype:uibuttontypecustom];
[Btn Setframe:cgrectmake (0+64*i, 0, 64, 49)];
Set the background picture of the button in the general state
[btn Setbackgroundimage:[uiimage Imagenamed:imagename] forstate:uicontrolstatenormal];
Sets the background picture when the button is selected
[btn Setbackgroundimage:[uiimage imagenamed:selectedimage] forstate:uicontrolstateselected];
[Btn Addtarget:self
Action: @selector (btnclicked:) forcontrolevents:uicontroleventtouchupinside];
Btn.tag = i;
if (i==0) {
btn.selected = YES;
}
[Bgview ADDSUBVIEW:BTN];
}
}
-(void) btnclicked: (UIButton *) btn
{
Click on a different button to switch between different view controllers
Self.selectedindex = Btn.tag;
Toggle display status for different btn
Uiimageview *bgview = (Uiimageview *) [Self.view viewwithtag:999];
For (UIView *subview in bgview.subviews) {
if ([SubView Iskindofclass:[uibutton class]]) {
UIButton *BTN1 = (UIButton *) SubView;
if (Btn1.tag = = Btn.tag) {
btn1.selected = YES;
}else{
btn1.selected = NO;
}
}
}
}
Customization of Tabbar