1.创建滚动视图
self.titleScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, 60)];
_titleScrollView.backgroundColor = [UIColor grayColor];
//设置滚动条
_titleScrollView.showsVerticalScrollIndicator = NO;
_titleScrollView.showsHorizontalScrollIndicator = NO;
_titleScrollView.bounces = NO;
_titleScrollView.contentSize = CGSizeMake(100*self.titlesArray.count,60);
[self.view addSubview:_titleScrollView];
2.添加按钮
for (int i = 0; i <_titlesArray.count; i ++) {
NSString *title = [self.titlesArray objectAtIndex:i];
//创建按钮
UIButton *titleButton = [[UIButton alloc] initWithFrame:CGRectMake(i*100, 0, 100, 60)];
[titleButton setTitle:title forState:UIControlStateNormal];
[titleButton setTitleColor:[UIColor blackColor] f