#pragma mark ViewCtrls
-(void)initViewCtrls
{
HomeViewController *home = [[HomeViewController alloc] init];
MessageViewController *msg = [[MessageViewController alloc] init];
ProfileViewController *profile = [[ProfileViewController alloc] init];
DiscoverViewController *discover = [[DiscoverViewController alloc] init];
MoreViewController *more = [[MoreViewController alloc] init];
NSArray *ctrls = @[home, msg, discover, profile, more];
[home release];
[msg release];
[profile release];
[discover release];
[more release];
NSMutableArray *navCtrls = [[NSMutableArray alloc] initWithCapacity:[ctrls count]];
for (UIViewController *viewCtrl in ctrls) {
BaseNavigationController *nav = [[BaseNavigationController alloc] initWithRootViewController:viewCtrl];
[navCtrls addObject:nav];
[nav release];
}
self.viewControllers = navCtrls;
[navCtrls release];
}
-(void)initTabbarView
{
float itemWidth = kScreenWidth/5;
_tabbarView = [[ThemeImgView alloc] initWithFrame:CGRectMake(0, kScreenHeight-49-20, kScreenWidth, 49)];
_tabbarView.imgName = @"mask_navbar.png";
_tabbarView.userInteractionEnabled = YES;
[self.view addSubview:_tabbarView];
[_tabbarView release];
_selectImgView = [[ThemeImgView alloc] initWithFrame:CGRectMake(0, 4, itemWidth, 45)];
_selectImgView.imgName = @"home_bottom_tab_arrow.png";
[_tabbarView addSubview:_selectImgView];
[_selectImgView release];
NSArray *imgArr = @[@"home_tab_icon_1.png", @"home_tab_icon_2.png", @"home_tab_icon_3.png", @"home_tab_icon_4.png", @"home_tab_icon_5.png"];
for (int i=0; i<imgArr.count; i++) {
ThemeButton *btn = [ThemeButton buttonWithType:UIButtonTypeCustom];
btn.showsTouchWhenHighlighted = YES;
btn.tag = i;
btn.frame = CGRectMake(i*itemWidth, 4, itemWidth, 45);
btn.imgName = imgArr[i];
[btn addTarget:self action:@selector(selectTabbar:) forControlEvents:UIControlEventTouchUpInside];
[_tabbarView addSubview:btn];
}
}
-(void)selectTabbar:(UIButton *)btn
{
self.selectedIndex = btn.tag;
[UIView animateWithDuration:0.2 animations:^{
_selectImgView.center = btn.center;
}];
}