修改UI
This commit is contained in:
@@ -6,8 +6,13 @@
|
||||
//
|
||||
|
||||
#import "HomeRankVC.h"
|
||||
#import "HomeRankContentVC.h"
|
||||
|
||||
@interface HomeRankVC ()
|
||||
@interface HomeRankVC ()<JXCategoryViewDelegate>
|
||||
@property (nonatomic, strong) NSArray *titles;
|
||||
@property (nonatomic, strong) JXCategoryTitleImageView *myCategoryView;
|
||||
@property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
|
||||
@property (nonatomic, assign) JXCategoryTitleImageType currentType;
|
||||
|
||||
@end
|
||||
|
||||
@@ -17,16 +22,124 @@
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view.
|
||||
self.view.backgroundColor = [UIColor grayColor];
|
||||
self.titles = @[@"螃蟹啊斯柯达积分卡", @"小龙虾", @"苹果", @"胡萝卜", @"葡萄", @"西瓜"];
|
||||
[self.view addSubview:self.myCategoryView];
|
||||
[self.view addSubview:self.listContainerView];
|
||||
// self.listContainerView.scrollView.scrollEnabled = false;
|
||||
NSArray *imageNames = @[@"crab", @"lobster", @"apple", @"carrot", @"grape", @"watermelon"];
|
||||
NSArray *selectedImageNames = @[@"crab_selected", @"lobster_selected", @"apple_selected", @"carrot_selected", @"grape_selected", @"watermelon_selected"];
|
||||
|
||||
self.myCategoryView.titles = self.titles;
|
||||
self.myCategoryView.imageInfoArray = imageNames;
|
||||
self.myCategoryView.selectedImageInfoArray = selectedImageNames;
|
||||
self.myCategoryView.loadImageBlock = ^(UIImageView *imageView, id info) {
|
||||
NSString *imageName = info;
|
||||
imageView.image = [UIImage imageNamed:imageName];
|
||||
};
|
||||
self.myCategoryView.imageZoomEnabled = YES;
|
||||
self.myCategoryView.imageZoomScale = 1.3;
|
||||
self.myCategoryView.averageCellSpacingEnabled = NO;
|
||||
|
||||
JXCategoryIndicatorLineView *lineView = [[JXCategoryIndicatorLineView alloc] init];
|
||||
lineView.indicatorWidth = 20;
|
||||
self.myCategoryView.indicators = @[lineView];
|
||||
|
||||
[self configCategoryViewWithType:JXCategoryTitleImageType_LeftImage];
|
||||
}
|
||||
|
||||
/*
|
||||
#pragma mark - Navigation
|
||||
- (void)viewDidLayoutSubviews {
|
||||
[super viewDidLayoutSubviews];
|
||||
|
||||
// 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.
|
||||
self.myCategoryView.frame = CGRectMake(0, 0, self.view.bounds.size.width, [self preferredCategoryViewHeight]);
|
||||
self.listContainerView.frame = CGRectMake(0, [self preferredCategoryViewHeight], self.view.bounds.size.width, self.view.bounds.size.height - [self preferredCategoryViewHeight]);
|
||||
}
|
||||
|
||||
//- (JXCategoryBaseView *)preferredCategoryView {
|
||||
// return [[JXCategoryBaseView alloc] init];
|
||||
//}
|
||||
|
||||
- (CGFloat)preferredCategoryViewHeight {
|
||||
return 50;
|
||||
}
|
||||
|
||||
- (void)configCategoryViewWithType:(JXCategoryTitleImageType)imageType {
|
||||
self.currentType = imageType;
|
||||
if ((NSInteger)imageType == 100) {
|
||||
NSMutableArray *types = [NSMutableArray array];
|
||||
for (int i = 0; i < self.titles.count; i++) {
|
||||
if (i == 2) {
|
||||
[types addObject:@(JXCategoryTitleImageType_OnlyImage)];
|
||||
}else if (i == 4) {
|
||||
[types addObject:@(JXCategoryTitleImageType_LeftImage)];
|
||||
}else {
|
||||
[types addObject:@(JXCategoryTitleImageType_OnlyTitle)];
|
||||
}
|
||||
}
|
||||
self.myCategoryView.imageTypes = types;
|
||||
}else {
|
||||
NSMutableArray *types = [NSMutableArray array];
|
||||
for (int i = 0; i < self.titles.count; i++) {
|
||||
[types addObject:@(imageType)];
|
||||
}
|
||||
self.myCategoryView.imageTypes = types;
|
||||
}
|
||||
[self.myCategoryView reloadData];
|
||||
}
|
||||
|
||||
// 分页菜单视图
|
||||
- (JXCategoryTitleImageView *)myCategoryView {
|
||||
if (!_myCategoryView) {
|
||||
_myCategoryView = [[JXCategoryTitleImageView alloc] init];
|
||||
_myCategoryView.delegate = self;
|
||||
|
||||
// !!!: 将列表容器视图关联到 categoryView
|
||||
_myCategoryView.listContainer = self.listContainerView;
|
||||
}
|
||||
return _myCategoryView;
|
||||
}
|
||||
|
||||
// 列表容器视图
|
||||
- (JXCategoryListContainerView *)listContainerView {
|
||||
if (!_listContainerView) {
|
||||
_listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
|
||||
}
|
||||
return _listContainerView;
|
||||
}
|
||||
|
||||
#pragma mark - JXCategoryViewDelegate
|
||||
|
||||
// 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。
|
||||
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index {
|
||||
NSLog(@"%@", NSStringFromSelector(_cmd));
|
||||
self.
|
||||
// 侧滑手势处理
|
||||
self.navigationController.interactivePopGestureRecognizer.enabled = (index == 0);
|
||||
}
|
||||
|
||||
// 滚动选中的情况才会调用该方法
|
||||
- (void)categoryView:(JXCategoryBaseView *)categoryView didScrollSelectedItemAtIndex:(NSInteger)index {
|
||||
NSLog(@"%@", NSStringFromSelector(_cmd));
|
||||
}
|
||||
|
||||
#pragma mark - JXCategoryListContainerViewDelegate
|
||||
|
||||
// 返回列表的数量
|
||||
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
|
||||
return self.titles.count;
|
||||
}
|
||||
|
||||
// 返回各个列表菜单下的实例,该实例需要遵守并实现 <JXCategoryListContentViewDelegate> 协议
|
||||
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
|
||||
HomeRankContentVC *list = [[HomeRankContentVC alloc] init];
|
||||
self.tableView = list.tableView;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - TitleImageSettingViewControllerDelegate
|
||||
|
||||
- (void)titleImageSettingVCDidSelectedImageType:(JXCategoryTitleImageType)imageType {
|
||||
[self configCategoryViewWithType:imageType];
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user