配置pod "LLSegmentBar"第三方
点进去了看文档
导入#import文件
#import “LLSegmentBarVC.h”
设置属性比如:
@property (nonatomic,weak) LLSegmentBarVC * segmentVC;
//懒加载:
-
(LLSegmentBarVC *)segmentVC{
if (!_segmentVC) {
LLSegmentBarVC *vc = [[LLSegmentBarVC alloc]init];
// 添加到到控制器
[self addChildViewController:vc];
_segmentVC = vc;
}
return _segmentVC;
} -
(void)viewDidLoad {
[super viewDidLoad];
self.automaticallyAdjustsScrollViewInsets = NO;
[self.navigationItem setHidesBackButton:YES];// 1 设置segmentBar的frame
self.segmentVC.segmentBar.frame = CGRectMake(0, 0, self.view.frame.size.width, 42);
self.navigationItem.titleView = self.segmentVC.segmentBar;
// 2 添加控制器的View
self.segmentVC.view.frame = CGRectMake(0, 0, self