If all you do is add buttons to the horizontal scroll view, you will do something like the following ...
- (void)createScrollMenu { UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 100)]; int x = 0; for (int i = 0; i < 8; i++) { UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(x, 0, 100, 100)]; [button setTitle:[NSString stringWithFormat:@"Button %d", i] forState:UIControlStateNormal]; [scrollView addSubview:button]; x += button.frame.size.width; } scrollView.contentSize = CGSizeMake(x, scrollView.frame.size.height); scrollView.backgroundColor = [UIColor redColor]; [self.view addSubview:scrollView]; }
This will create a scrollview with a height of 100, a width the size of the parent and add 8 buttons to it.
source share