iOS 多个UIViewController之间滑动切换
#import "JYPageView.h"
@property (nonatomic, strong) JYPageView *pageView;
self.automaticallyAdjustsScrollViewInsets = NO;
NSArray* titles = @[@"测试测试测试测试测试",
@"音乐音乐音乐音乐",
@"段子段子段子",
@"新闻",
@"体"];
NSMutableArray<UIViewController *> *childVCs = [NSMutableArray array];
for (int i = 0; i < titles.count; i ++) {
UIViewController *childVC = [[UIViewController alloc] init];
childVC.view.backgroundColor = [UIColor randomColor];
[childVCs addObject:childVC];
}
CGRect rect = CGRectMake(0,
64,
self.view.frame.size.width,
self.view.frame.size.height - 64);
JYTitleStyle *style = [JYTitleStyle defaultStyle];
style.titleHeight = 44;
self.pageView = [[JYPageView alloc] initWithFrame:rect
style:style
titles:titles
parentViewController:self
childViewControllers:childVCs];
self.pageView.delegate = self;
[self.view addSubview:self.pageView];
#pragma mark - Delegate
- (void)JYPageView:(JYPageView *)pageView didSelectedItemAtIndex:(NSInteger)index
{
NSLog(@"%ld", index);
}