#import "NewsViewController.h"
#import "VideoViewController.h"
#import "ReaderViewController.h"
#import "ScienceViewController.h"
#import "SocietyViewController.h"
#import "HotViewController.h"
#import "TopLineViewController.h"
#import "TitleButton.h"
#define ScreenW [UIScreen mainScreen].bounds.size.width
#define ScreenH [UIScreen mainScreen].bounds.size.height
@interface NewsViewController ()<UIScrollViewDelegate>
@property (nonatomic, strong) UIButton *selButton;
@property (nonatomic, strong) NSMutableArray *titleBtns;
// 标题滚动view
@property (weak, nonatomic) IBOutlet UIScrollView *titileScrollView;
// 内容滚动view
@property (weak, nonatomic) IBOutlet UIScrollView *contentView;
@end
@implementation NewsViewController
- (NSMutableArray *)titleBtns
{
if (_titleBtns == nil) {
_titleBtns = [NSMutableArray array];
}
return _titleBtns;
}
// 头条,热点,视频,社会,订阅,科技(science)
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
// 添加所有子控制器
[self setUpChildViewController];
// 设置标题
[self setUpTitle];
// iOS7之后,导航控制器下所有ScrollView都会添加额外滚动区域
self.automaticallyAdjustsScrollViewInsets = NO;
// 初始化scrollView
[self setUpScrollView];
}
- (void)setUpScrollView
{
self.titileScrollView.showsHorizontalScrollIndicator = NO;
self.contentView.contentSize = CGSizeMake(self.childViewControllers.count * [UIScreen mainScreen].bounds.size.width, 0);
self.contentView.showsHorizontalScrollIndicator = NO;
self.contentView.pagingEnabled = YES;
self.contentView.bounces = NO;
self.contentView.delegate = self;
}
- (void)setUpChildViewController
{
TopLineViewController *topLineVc = [[TopLineViewController alloc] init];
topLineVc.title = @"头条";
[self addChildViewController:topLineVc];
HotViewController *hotVc = [[HotViewController alloc] init];
hotVc.title = @"热点";
[self addChildViewController:hotVc];
VideoViewController *videoVc = [[VideoViewController alloc] init];
videoVc.title = @"视频";
[self addChildViewController:videoVc];
SocietyViewController *societyVc = [[SocietyViewController alloc] init];
societyVc.title = @"社会";
[self addChildViewController:societyVc];
ReaderViewController *readerVc = [[ReaderViewCont