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

No comments: