lel*_*108 14 user-interface xcode objective-c ios
我有兴趣创建这样的菜单栏:

从我一直在阅读,我应该做一个UIScrollView.有没有在线的例子,无限滚动(环绕菜单栏)和触摸控制的能力?(即滑动并更改菜单栏).
谢谢!
您的要求与我的非常相似.但我也找不到足够好的解决方案.所以我决定自己创造一些东西.
该ACTabScrollView支持一些不同的手势.而tabs和pages永远同步滚动.
Swipe 通常的页面Drag 标签可以快速移动页面Click 用于更改为该页面的选项卡

该Infinite Scrolling功能尚未准备好,但我将继续实施.
我在此项目中使用类似的UI作为示例.我不知道该应用程序是什么,但如果使用它作为一个例子打扰任何人.联系我,我会立即删除.
随意给我任何改进它的建议:)
我希望这段代码对您有用。
- (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);
}
Run Code Online (Sandbox Code Playgroud)
您可以根据需要设置滚动内容和菜单按钮。根据按钮单击更改视图。这是上面代码的屏幕截图

| 归档时间: |
|
| 查看次数: |
12314 次 |
| 最近记录: |