测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | MIT |
发布最新发布 | 2016 年 5 月 |
由 Abdullah Md. Zubair 维护。
通常,当标签栏控制器中有 5 个以上的标签时,标签栏会显示更多标签。为了解决这个问题,您可以使用 ZRScrollableTabBar,这可以让您放入任意数量的标签,并且它们是可滚动的。
示例截图
为了运行示例项目,请先克隆存储库,然后从 Example 目录中首先运行 pod install
。
使用示例
-(void)initScrollableTabbar
{
// Tab bar
UITabBarItem *item1 = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:1];
UITabBarItem *item2 = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemContacts tag:2];
UITabBarItem *item3 = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemDownloads tag:3];
UITabBarItem *item4 = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFeatured tag:4];
UITabBarItem *item5 = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemRecents tag:5];
UITabBarItem *item6 = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemTopRated tag:6];
UITabBarItem *item7 = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemRecents tag:7];
UITabBarItem *item8 = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemContacts tag:8];
UITabBarItem *item9 = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:9];
ZRScrollableTabBar *tabBar = [[ZRScrollableTabBar alloc] initWithItems:[NSArray arrayWithObjects: item1, item2, item3, item4, item5, item6, item7, item8, item9, nil]];
tabBar.scrollableTabBarDelegate = self;
[self.view addSubview:tabBar];
}
您将在代理方法中获取有选中索引的标签栏
- (void)scrollableTabBar:(ZRScrollableTabBar *)tabBar didSelectItemWithTag:(int)tag
{
....
}
iOS 7+,适用于 iPhone 和 iPad
Abdullah Md. Zubair,[email protected]
(MIT 许可证)
版权所有 (c) 2015 Abdullah Md. Zubair [email protected]
在此特此免费授予任何获得本软件及其相关文档副本(以下简称“软件”)的个人权限,无限制地处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售该软件副本,并允许获得该软件的个人做上述操作,前提是
上述版权声明和本许可声明应包含在软件的所有副本或实质性部分中。
软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于对适销性、针对特定目的的适用性和非侵权的保证。在任何情况下,作者或版权所有者均不对任何主张、损害或其他责任承担责任,无论是基于合同、侵权或其他原因,由软件、其使用或其他操作引起。