类似网易新闻和懂球帝应用的标签视图。您可以滚动顶部标签并点击标签项来切换底部的内容,或者您也可以直接在内容视图中通过左右滑动切换内容。
类似于网易新闻和懂球帝应用的平铺导航控件。顶部导航栏可滑动,可点击切换栏目。也可以在内容视图中通过左右滑动来切换栏目。
使用 TopScrollTabView 有两种方式:1. 使用 Cocoapods;2. 将 TSTView.h, TSTView.m, NSLayoutConstraint+Util.h, NSLayoutConstraint+Util.m 复制到您的项目中。
集成方式有两种:1. 通过 Cocoapods;2. 直接将以下四个文件复制到项目中:TSTView.h, TSTView.m, NSLayoutConstraint+Util.h, NSLayoutConstraint+Util.m
您可以使用此视图如下所示:
使用方法请参考以下代码:
#import "TSTView.h"
- (void)viewDidLoad {
[super viewDidLoad];
tstview = [[TSTView alloc] init];
tstview.dataSource = self;
tstview.delegate = self;
//this is important for content view reuse
[tstview registerReusableContentViewClass:[UIView class]];
[self.view addSubview:tstview];
[tstview reloadData];
}
您可以实现 TSTView 代理方法以定义 TSTView 的外观
可以通过代理方法设置 TSTView 的外观以符合您的个性化需求:
- (UIColor *)tabViewBackgroundColorForTSTView:(TSTView *)tstview;
- (UIColor *)highlightColorForTSTView:(TSTView *)tstview;
- (UIColor *)normalColorForTSTView:(TSTView *)tstview;
- (UIColor *)normalColorForSeparatorInTSTView:(TSTView *)tstview;
- (CGFloat)heightForTabInTSTView:(TSTView *)tstview;
- (CGFloat)heightForTabSeparatorInTSTView:(TSTView *)tstview;
- (CGFloat)heightForSelectedIndicatorInTSTView:(TSTView *)tstview;
- (UIFont *)fontForTabTitleInTSTView:(TSTView *)tstview;