Showing posts with label tabbar. Show all posts
Showing posts with label tabbar. Show all posts

Wednesday, December 21, 2011

Customizing the TabBar images in iOS



Here is the sample code for you how to customize the tabbar in iphone. It will do with four stripe of images.




- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
NSUInteger selectedIndex = tabBarController.selectedIndex;

NSString *selectedImage;

switch (selectedIndex) {
case 0:
selectedImage = @"menu_selected.png";
break;
case 1:
selectedImage = @"location_selected.png";
break;
case 2:
selectedImage = @"offers_selected.png";
break;
case 3:
selectedImage = @"reviews_selected.png";
break;
default:
break;
}


UIImage *image = [UIImage imageNamed:selectedImage];
UIImageView *imageView = [[ UIImageView alloc ] initWithFrame:CGRectMake(0,440,320,40) ];
imageView.image = image;
[self.tabBarController.view addSubview:imageView];

}

Added: Source will do SKTabBar usage

Source: download

Friday, December 16, 2011

Custom ScrollableTabBar (UIButtons) for iOS


One of my Project I need to build scrollable buttons/tab bar in the page. So, idea comes with this solutions.

How to call the SKTabBar class:

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {

CGSize buttonSize = CGSizeMake(50,60);

SKTabBar *skTB =[[SKTabBar alloc]initWithFrame:CGRectMake(0,100,320,100)];
[skTB setBackgroundColor:[UIColor grayColor]];
[skTB setShowsVerticalScrollIndicator:NO];
[skTB setSkDelegate:self];
[skTB loadTabs:buttonSize numberOfTabs:36];
[self.view addSubview:skTB];

[super viewDidLoad];
}

-(void)getSelectedButtonTab:(id)sender{
UIButton *btn = (UIButton*)sender;
NSLog(@"%d",btn.tag);
}

Updated:

Added animations code snippets to show the zoomed view of selected button on selection.

Source: download