I hope this code will work for you.
- (void)viewDidLoad
{
[super viewDidLoad];
[self createHorizontalScroll];
}
- (void)createHorizontalScroll
{
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 80, self.view.frame.size.width, 80)];
int buttonX = 0;
for (int i = 0; i < 5; i++)
{
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(buttonX, 0, 100, 60)];
[button setTitle:[NSString stringWithFormat:@"Button %d", i] forState:UIControlStateNormal];
[scrollView addSubview:button];
buttonX = buttonX+button.frame.size.width;
[button addTarget:self
action:@selector(changeView:)
forControlEvents:UIControlEventTouchUpInside];
}
scrollView.contentSize = CGSizeMake(buttonX, scrollView.frame.size.height);
scrollView.backgroundColor = [UIColor greenColor];
[self.view addSubview:scrollView];
}
-(void)changeView:(UIButton*)sender
{
NSLog(@"I Clicked a button %ld",(long)sender.tag);
}
You can set scroll content as much you want and menu buttons.Change the view according to the button click. Here the screen shot of the above code
