修改UI
This commit is contained in:
13
Pods/JXCategoryView/Sources/Dot/JXCategoryDotCell.h
generated
Normal file
13
Pods/JXCategoryView/Sources/Dot/JXCategoryDotCell.h
generated
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// JXCategoryDotCell.h
|
||||
// JXCategoryView
|
||||
//
|
||||
// Created by jiaxin on 2018/8/20.
|
||||
// Copyright © 2018年 jiaxin. All rights reserved.
|
||||
//
|
||||
|
||||
#import "JXCategoryTitleCell.h"
|
||||
|
||||
@interface JXCategoryDotCell : JXCategoryTitleCell
|
||||
|
||||
@end
|
||||
64
Pods/JXCategoryView/Sources/Dot/JXCategoryDotCell.m
generated
Normal file
64
Pods/JXCategoryView/Sources/Dot/JXCategoryDotCell.m
generated
Normal file
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// JXCategoryDotCell.m
|
||||
// JXCategoryView
|
||||
//
|
||||
// Created by jiaxin on 2018/8/20.
|
||||
// Copyright © 2018年 jiaxin. All rights reserved.
|
||||
//
|
||||
|
||||
#import "JXCategoryDotCell.h"
|
||||
#import "JXCategoryDotCellModel.h"
|
||||
|
||||
@interface JXCategoryDotCell ()
|
||||
@property (nonatomic, strong) UIView *dot;
|
||||
@end
|
||||
|
||||
@implementation JXCategoryDotCell
|
||||
|
||||
- (void)initializeViews {
|
||||
[super initializeViews];
|
||||
|
||||
_dot = [[UIView alloc] init];
|
||||
[self.contentView addSubview:self.dot];
|
||||
self.dot.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
}
|
||||
|
||||
- (void)reloadData:(JXCategoryBaseCellModel *)cellModel {
|
||||
[super reloadData:cellModel];
|
||||
|
||||
JXCategoryDotCellModel *myCellModel = (JXCategoryDotCellModel *)cellModel;
|
||||
self.dot.hidden = !myCellModel.dotHidden;
|
||||
self.dot.backgroundColor = myCellModel.dotColor;
|
||||
self.dot.layer.cornerRadius = myCellModel.dotCornerRadius;
|
||||
[NSLayoutConstraint deactivateConstraints:self.dot.constraints];
|
||||
[self.dot.widthAnchor constraintEqualToConstant:myCellModel.dotSize.width].active = YES;
|
||||
[self.dot.heightAnchor constraintEqualToConstant:myCellModel.dotSize.height].active = YES;
|
||||
switch (myCellModel.relativePosition) {
|
||||
case JXCategoryDotRelativePosition_TopLeft:
|
||||
{
|
||||
[self.dot.centerXAnchor constraintEqualToAnchor:self.titleLabel.leadingAnchor constant:myCellModel.dotOffset.x].active = YES;
|
||||
[self.dot.centerYAnchor constraintEqualToAnchor:self.titleLabel.topAnchor constant:myCellModel.dotOffset.y].active = YES;
|
||||
}
|
||||
break;
|
||||
case JXCategoryDotRelativePosition_TopRight:
|
||||
{
|
||||
[self.dot.centerXAnchor constraintEqualToAnchor:self.titleLabel.trailingAnchor constant:myCellModel.dotOffset.x].active = YES;
|
||||
[self.dot.centerYAnchor constraintEqualToAnchor:self.titleLabel.topAnchor constant:myCellModel.dotOffset.y].active = YES;
|
||||
}
|
||||
break;
|
||||
case JXCategoryDotRelativePosition_BottomLeft:
|
||||
{
|
||||
[self.dot.centerXAnchor constraintEqualToAnchor:self.titleLabel.leadingAnchor constant:myCellModel.dotOffset.x].active = YES;
|
||||
[self.dot.centerYAnchor constraintEqualToAnchor:self.titleLabel.bottomAnchor constant:myCellModel.dotOffset.y].active = YES;
|
||||
}
|
||||
break;
|
||||
case JXCategoryDotRelativePosition_BottomRight:
|
||||
{
|
||||
[self.dot.centerXAnchor constraintEqualToAnchor:self.titleLabel.trailingAnchor constant:myCellModel.dotOffset.x].active = YES;
|
||||
[self.dot.centerYAnchor constraintEqualToAnchor:self.titleLabel.bottomAnchor constant:myCellModel.dotOffset.y].active = YES;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
27
Pods/JXCategoryView/Sources/Dot/JXCategoryDotCellModel.h
generated
Normal file
27
Pods/JXCategoryView/Sources/Dot/JXCategoryDotCellModel.h
generated
Normal file
@@ -0,0 +1,27 @@
|
||||
//
|
||||
// JXCategoryDotCellModel.h
|
||||
// JXCategoryView
|
||||
//
|
||||
// Created by jiaxin on 2018/8/20.
|
||||
// Copyright © 2018年 jiaxin. All rights reserved.
|
||||
//
|
||||
|
||||
#import "JXCategoryTitleCellModel.h"
|
||||
|
||||
typedef NS_ENUM(NSUInteger, JXCategoryDotRelativePosition) {
|
||||
JXCategoryDotRelativePosition_TopLeft = 0,
|
||||
JXCategoryDotRelativePosition_TopRight,
|
||||
JXCategoryDotRelativePosition_BottomLeft,
|
||||
JXCategoryDotRelativePosition_BottomRight,
|
||||
};
|
||||
|
||||
@interface JXCategoryDotCellModel : JXCategoryTitleCellModel
|
||||
|
||||
@property (nonatomic, assign) BOOL dotHidden;
|
||||
@property (nonatomic, assign) JXCategoryDotRelativePosition relativePosition;
|
||||
@property (nonatomic, assign) CGSize dotSize;
|
||||
@property (nonatomic, assign) CGFloat dotCornerRadius;
|
||||
@property (nonatomic, strong) UIColor *dotColor;
|
||||
@property (nonatomic, assign) CGPoint dotOffset;
|
||||
|
||||
@end
|
||||
13
Pods/JXCategoryView/Sources/Dot/JXCategoryDotCellModel.m
generated
Normal file
13
Pods/JXCategoryView/Sources/Dot/JXCategoryDotCellModel.m
generated
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// JXCategoryDotCellModel.m
|
||||
// JXCategoryView
|
||||
//
|
||||
// Created by jiaxin on 2018/8/20.
|
||||
// Copyright © 2018年 jiaxin. All rights reserved.
|
||||
//
|
||||
|
||||
#import "JXCategoryDotCellModel.h"
|
||||
|
||||
@implementation JXCategoryDotCellModel
|
||||
|
||||
@end
|
||||
30
Pods/JXCategoryView/Sources/Dot/JXCategoryDotView.h
generated
Normal file
30
Pods/JXCategoryView/Sources/Dot/JXCategoryDotView.h
generated
Normal file
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// JXCategoryDotView.h
|
||||
// JXCategoryView
|
||||
//
|
||||
// Created by jiaxin on 2018/8/20.
|
||||
// Copyright © 2018年 jiaxin. All rights reserved.
|
||||
//
|
||||
|
||||
#import "JXCategoryTitleView.h"
|
||||
#import "JXCategoryDotCell.h"
|
||||
#import "JXCategoryDotCellModel.h"
|
||||
|
||||
@interface JXCategoryDotView : JXCategoryTitleView
|
||||
|
||||
//相对于titleLabel的位置,默认:JXCategoryDotRelativePosition_TopRight
|
||||
@property (nonatomic, assign) JXCategoryDotRelativePosition relativePosition;
|
||||
//@[@(布尔值)]数组,控制红点是否显示
|
||||
@property (nonatomic, strong) NSArray <NSNumber *> *dotStates;
|
||||
//红点的尺寸。默认:CGSizeMake(10, 10)
|
||||
@property (nonatomic, assign) CGSize dotSize;
|
||||
//红点的圆角值。默认:JXCategoryViewAutomaticDimension(self.dotSize.height/2)
|
||||
@property (nonatomic, assign) CGFloat dotCornerRadius;
|
||||
//红点的颜色。默认:[UIColor redColor]
|
||||
@property (nonatomic, strong) UIColor *dotColor;
|
||||
/**
|
||||
红点 x,y方向的偏移 (+值:水平方向向右,竖直方向向下)
|
||||
*/
|
||||
@property (nonatomic, assign) CGPoint dotOffset;
|
||||
|
||||
@end
|
||||
52
Pods/JXCategoryView/Sources/Dot/JXCategoryDotView.m
generated
Normal file
52
Pods/JXCategoryView/Sources/Dot/JXCategoryDotView.m
generated
Normal file
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// JXCategoryDotView.m
|
||||
// JXCategoryView
|
||||
//
|
||||
// Created by jiaxin on 2018/8/20.
|
||||
// Copyright © 2018年 jiaxin. All rights reserved.
|
||||
//
|
||||
|
||||
#import "JXCategoryDotView.h"
|
||||
|
||||
@implementation JXCategoryDotView
|
||||
|
||||
- (void)initializeData {
|
||||
[super initializeData];
|
||||
|
||||
_relativePosition = JXCategoryDotRelativePosition_TopRight;
|
||||
_dotSize = CGSizeMake(10, 10);
|
||||
_dotCornerRadius = JXCategoryViewAutomaticDimension;
|
||||
_dotColor = [UIColor redColor];
|
||||
_dotOffset = CGPointZero;
|
||||
}
|
||||
|
||||
- (Class)preferredCellClass {
|
||||
return [JXCategoryDotCell class];
|
||||
}
|
||||
|
||||
- (void)refreshDataSource {
|
||||
NSMutableArray *tempArray = [NSMutableArray arrayWithCapacity:self.titles.count];
|
||||
for (int i = 0; i < self.titles.count; i++) {
|
||||
JXCategoryDotCellModel *cellModel = [[JXCategoryDotCellModel alloc] init];
|
||||
[tempArray addObject:cellModel];
|
||||
}
|
||||
self.dataSource = [NSArray arrayWithArray:tempArray];
|
||||
}
|
||||
|
||||
- (void)refreshCellModel:(JXCategoryBaseCellModel *)cellModel index:(NSInteger)index {
|
||||
[super refreshCellModel:cellModel index:index];
|
||||
|
||||
JXCategoryDotCellModel *myCellModel = (JXCategoryDotCellModel *)cellModel;
|
||||
myCellModel.dotHidden = [self.dotStates[index] boolValue];
|
||||
myCellModel.relativePosition = self.relativePosition;
|
||||
myCellModel.dotSize = self.dotSize;
|
||||
myCellModel.dotColor = self.dotColor;
|
||||
myCellModel.dotOffset = self.dotOffset;
|
||||
if (self.dotCornerRadius == JXCategoryViewAutomaticDimension) {
|
||||
myCellModel.dotCornerRadius = self.dotSize.height/2;
|
||||
}else {
|
||||
myCellModel.dotCornerRadius = self.dotCornerRadius;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user