关注和最新数据的处理
This commit is contained in:
@@ -6,26 +6,145 @@
|
||||
//
|
||||
|
||||
#import "XPMonentsViewController.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <JXCategoryView/JXCategoryView.h>
|
||||
#import <JXCategoryView/JXCategoryListContainerView.h>
|
||||
///Tool
|
||||
#import "ThemeColor.h"
|
||||
#import "XPMacro.h"
|
||||
///View
|
||||
#import "XPMonentsRecommendViewController.h"
|
||||
#import "XPMonentsAttentionViewController.h"
|
||||
#import "XPMonentsLatestViewController.h"
|
||||
|
||||
@interface XPMonentsViewController ()
|
||||
|
||||
@interface XPMonentsViewController ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
|
||||
///标题
|
||||
@property (nonatomic,strong) NSArray<NSString *> *titles;
|
||||
///导航栏
|
||||
@property (nonatomic,strong) UIView * navView;
|
||||
///消息的
|
||||
@property (nonatomic,strong) UIButton *messageButton;
|
||||
///滑块
|
||||
@property (nonatomic,strong) JXCategoryTitleView *titleView;
|
||||
@property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
|
||||
@end
|
||||
|
||||
@implementation XPMonentsViewController
|
||||
|
||||
- (BOOL)isHiddenNavBar {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
[super viewDidLoad];
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
|
||||
/*
|
||||
#pragma mark - Navigation
|
||||
|
||||
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
||||
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
||||
// Get the new view controller using [segue destinationViewController].
|
||||
// Pass the selected object to the new view controller.
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[self.view addSubview:self.navView];
|
||||
[self.view addSubview:self.listContainerView];
|
||||
|
||||
[self.navView addSubview:self.titleView];
|
||||
[self.navView addSubview:self.messageButton];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.mas_equalTo(self.view);
|
||||
make.height.mas_equalTo(kNavigationHeight);
|
||||
}];
|
||||
|
||||
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self.navView);
|
||||
make.height.mas_equalTo(20);
|
||||
make.top.mas_equalTo(self.navView).offset(kSafeAreaTopHeight + 40);
|
||||
}];
|
||||
|
||||
[self.messageButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerY.mas_equalTo(self.titleView);
|
||||
make.right.mas_equalTo(self.navView).offset(-15);
|
||||
make.size.mas_equalTo(CGSizeMake(22, 22));
|
||||
}];
|
||||
|
||||
[self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.bottom.mas_equalTo(self.view);
|
||||
make.top.mas_equalTo(self.navView.mas_bottom);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - JXCategoryListContainerViewDelegate
|
||||
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
|
||||
return self.titles.count;
|
||||
}
|
||||
|
||||
// 根据下标 index 返回对应遵守并实现 `JXCategoryListContentViewDelegate` 协议的列表实例
|
||||
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
|
||||
if (index == 0) {
|
||||
XPMonentsAttentionViewController * attentionVC = [[XPMonentsAttentionViewController alloc] init];
|
||||
return attentionVC;
|
||||
}else if (index == 1) {
|
||||
XPMonentsRecommendViewController * recommendVC = [[XPMonentsRecommendViewController alloc] init];
|
||||
return recommendVC;
|
||||
} else if(index == 2) {
|
||||
XPMonentsLatestViewController * latestVC = [[XPMonentsLatestViewController alloc] init];
|
||||
return latestVC;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (JXCategoryListContainerView *)listContainerView {
|
||||
if (!_listContainerView) {
|
||||
_listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
|
||||
_listContainerView.listCellBackgroundColor = [UIColor clearColor];
|
||||
}
|
||||
return _listContainerView;
|
||||
}
|
||||
|
||||
- (JXCategoryTitleView *)titleView {
|
||||
if (!_titleView) {
|
||||
_titleView = [[JXCategoryTitleView alloc] initWithFrame:CGRectZero];
|
||||
_titleView.backgroundColor =[UIColor clearColor];
|
||||
_titleView.delegate = self;
|
||||
_titleView.titleColor = [ThemeColor secondTextColor];
|
||||
_titleView.titleSelectedColor = [ThemeColor mainTextColor];
|
||||
_titleView.titleFont = [UIFont systemFontOfSize:15 weight:UIFontWeightSemibold];
|
||||
_titleView.titleSelectedFont = [UIFont systemFontOfSize:20 weight:UIFontWeightHeavy];
|
||||
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
|
||||
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
|
||||
_titleView.averageCellSpacingEnabled = NO;
|
||||
_titleView.defaultSelectedIndex = 0;
|
||||
_titleView.cellSpacing = 20;
|
||||
_titleView.titles = self.titles;
|
||||
_titleView.listContainer = self.listContainerView;
|
||||
_titleView.defaultSelectedIndex = 1;
|
||||
CGFloat itemWidth = [@"推荐" boundingRectWithSize:CGSizeMake(100, CGFLOAT_MAX) options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20 weight:UIFontWeightHeavy]} context:nil].size.width;
|
||||
_titleView.cellWidth = itemWidth;
|
||||
_titleView.contentEdgeInsetLeft = (KScreenWidth - itemWidth * self.titles.count - 20 * (self.titles.count - 1))/ 2;
|
||||
}
|
||||
return _titleView;
|
||||
}
|
||||
|
||||
- (UIView *)navView {
|
||||
if (!_navView) {
|
||||
_navView = [[UIView alloc] init];
|
||||
_navView.backgroundColor = [ThemeColor appCellBackgroundColor];
|
||||
}
|
||||
return _navView;
|
||||
}
|
||||
|
||||
- (NSArray<NSString *> *)titles {
|
||||
if (!_titles) {
|
||||
_titles = @[@"关注",@"推荐", @"最新"];
|
||||
}
|
||||
return _titles;
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user