修改UI
This commit is contained in:
17
Pods/JXCategoryView/Sources/VerticalZoomTitle/JXCategoryTitleVerticalZoomCell.h
generated
Normal file
17
Pods/JXCategoryView/Sources/VerticalZoomTitle/JXCategoryTitleVerticalZoomCell.h
generated
Normal file
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// JXCategoryTitleVerticalZoomCell.h
|
||||
// JXCategoryView
|
||||
//
|
||||
// Created by jiaxin on 2019/2/14.
|
||||
// Copyright © 2019 jiaxin. All rights reserved.
|
||||
//
|
||||
|
||||
#import "JXCategoryTitleCell.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface JXCategoryTitleVerticalZoomCell : JXCategoryTitleCell
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
45
Pods/JXCategoryView/Sources/VerticalZoomTitle/JXCategoryTitleVerticalZoomCell.m
generated
Normal file
45
Pods/JXCategoryView/Sources/VerticalZoomTitle/JXCategoryTitleVerticalZoomCell.m
generated
Normal file
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// JXCategoryTitleVerticalZoomCell.m
|
||||
// JXCategoryView
|
||||
//
|
||||
// Created by jiaxin on 2019/2/14.
|
||||
// Copyright © 2019 jiaxin. All rights reserved.
|
||||
//
|
||||
|
||||
#import "JXCategoryTitleVerticalZoomCell.h"
|
||||
#import "JXCategoryTitleVerticalZoomCellModel.h"
|
||||
|
||||
@implementation JXCategoryTitleVerticalZoomCell
|
||||
|
||||
- (void)reloadData:(JXCategoryBaseCellModel *)cellModel {
|
||||
[super reloadData:cellModel];
|
||||
|
||||
JXCategoryTitleVerticalZoomCellModel *myCellModel = (JXCategoryTitleVerticalZoomCellModel *)cellModel;
|
||||
|
||||
if (myCellModel.isTitleLabelZoomEnabled) {
|
||||
//先把font设置为缩放的最大值,再缩小到最小值,最后根据当前的titleLabelZoomScale值,进行缩放更新。这样就能避免transform从小到大时字体模糊
|
||||
UIFont *maxScaleFont = [UIFont fontWithDescriptor:myCellModel.titleFont.fontDescriptor size:myCellModel.titleFont.pointSize*myCellModel.maxVerticalFontScale];
|
||||
CGFloat baseScale = myCellModel.titleFont.lineHeight/maxScaleFont.lineHeight;
|
||||
if (myCellModel.isSelectedAnimationEnabled && [self checkCanStartSelectedAnimation:myCellModel]) {
|
||||
JXCategoryCellSelectedAnimationBlock block = [self preferredTitleZoomAnimationBlock:myCellModel baseScale:baseScale];
|
||||
[self addSelectedAnimationBlock:block];
|
||||
} else {
|
||||
self.titleLabel.font = maxScaleFont;
|
||||
self.maskTitleLabel.font = maxScaleFont;
|
||||
CGAffineTransform currentTransform = CGAffineTransformMakeScale(baseScale*myCellModel.titleLabelCurrentZoomScale, baseScale*myCellModel.titleLabelCurrentZoomScale);
|
||||
self.titleLabel.transform = currentTransform;
|
||||
self.maskTitleLabel.transform = currentTransform;
|
||||
}
|
||||
} else {
|
||||
if (myCellModel.isSelected) {
|
||||
self.titleLabel.font = myCellModel.titleSelectedFont;
|
||||
self.maskTitleLabel.font = myCellModel.titleSelectedFont;
|
||||
}else {
|
||||
self.titleLabel.font = myCellModel.titleFont;
|
||||
self.maskTitleLabel.font = myCellModel.titleFont;
|
||||
}
|
||||
}
|
||||
|
||||
[self.titleLabel sizeToFit];
|
||||
}
|
||||
@end
|
||||
19
Pods/JXCategoryView/Sources/VerticalZoomTitle/JXCategoryTitleVerticalZoomCellModel.h
generated
Normal file
19
Pods/JXCategoryView/Sources/VerticalZoomTitle/JXCategoryTitleVerticalZoomCellModel.h
generated
Normal file
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// JXCategoryTitleVerticalZoomCellModel.h
|
||||
// JXCategoryView
|
||||
//
|
||||
// Created by jiaxin on 2019/2/14.
|
||||
// Copyright © 2019 jiaxin. All rights reserved.
|
||||
//
|
||||
|
||||
#import "JXCategoryTitleCellModel.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface JXCategoryTitleVerticalZoomCellModel : JXCategoryTitleCellModel
|
||||
|
||||
@property (nonatomic, assign) CGFloat maxVerticalFontScale;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
13
Pods/JXCategoryView/Sources/VerticalZoomTitle/JXCategoryTitleVerticalZoomCellModel.m
generated
Normal file
13
Pods/JXCategoryView/Sources/VerticalZoomTitle/JXCategoryTitleVerticalZoomCellModel.m
generated
Normal file
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// JXCategoryTitleVerticalZoomCellModel.m
|
||||
// JXCategoryView
|
||||
//
|
||||
// Created by jiaxin on 2019/2/14.
|
||||
// Copyright © 2019 jiaxin. All rights reserved.
|
||||
//
|
||||
|
||||
#import "JXCategoryTitleVerticalZoomCellModel.h"
|
||||
|
||||
@implementation JXCategoryTitleVerticalZoomCellModel
|
||||
|
||||
@end
|
||||
34
Pods/JXCategoryView/Sources/VerticalZoomTitle/JXCategoryTitleVerticalZoomView.h
generated
Normal file
34
Pods/JXCategoryView/Sources/VerticalZoomTitle/JXCategoryTitleVerticalZoomView.h
generated
Normal file
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// JXCategoryTitleVerticalZoomView.h
|
||||
// JXCategoryView
|
||||
//
|
||||
// Created by jiaxin on 2019/2/14.
|
||||
// Copyright © 2019 jiaxin. All rights reserved.
|
||||
//
|
||||
|
||||
#import "JXCategoryTitleView.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
垂直方向的缩放值范围:minVerticalFontScale~maxVerticalFontScale;
|
||||
垂直方向cellSpacing范围:minVerticalCellSpacing~maxVerticalCellSpacing,用于达到缩小时cell更加紧凑
|
||||
根据UI设计师给你的参数,去多次尝试设置上面的值来达到同样的效果。多尝试几次就知道每个属性设置之后的效果。
|
||||
*/
|
||||
@interface JXCategoryTitleVerticalZoomView : JXCategoryTitleView
|
||||
|
||||
@property (nonatomic, assign) CGFloat maxVerticalFontScale; //垂直方向最大的缩放值
|
||||
@property (nonatomic, assign) CGFloat minVerticalFontScale; //垂直方向最小的缩放值
|
||||
@property (nonatomic, assign) CGFloat maxVerticalCellSpacing; //垂直方向最大的cellSpacing
|
||||
@property (nonatomic, assign) CGFloat minVerticalCellSpacing; //垂直方向最小的cellSpacing
|
||||
|
||||
/**
|
||||
当前列表滚动时,根据当前垂直方向categoryView高度变化的百分比,刷新布局
|
||||
|
||||
@param percent 当前垂直方向categoryView高度变化百分比
|
||||
*/
|
||||
- (void)listDidScrollWithVerticalHeightPercent:(CGFloat)percent;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
94
Pods/JXCategoryView/Sources/VerticalZoomTitle/JXCategoryTitleVerticalZoomView.m
generated
Normal file
94
Pods/JXCategoryView/Sources/VerticalZoomTitle/JXCategoryTitleVerticalZoomView.m
generated
Normal file
@@ -0,0 +1,94 @@
|
||||
//
|
||||
// JXCategoryTitleVerticalZoomView.m
|
||||
// JXCategoryView
|
||||
//
|
||||
// Created by jiaxin on 2019/2/14.
|
||||
// Copyright © 2019 jiaxin. All rights reserved.
|
||||
//
|
||||
|
||||
#import "JXCategoryTitleVerticalZoomView.h"
|
||||
#import "JXCategoryTitleVerticalZoomCellModel.h"
|
||||
#import "JXCategoryTitleVerticalZoomCell.h"
|
||||
#import "JXCategoryFactory.h"
|
||||
|
||||
@interface JXCategoryTitleVerticalZoomView ()
|
||||
@property (nonatomic, assign) CGFloat currentVerticalScale; //当前垂直方向的缩放基准值
|
||||
@end
|
||||
|
||||
@implementation JXCategoryTitleVerticalZoomView
|
||||
|
||||
- (void)initializeData {
|
||||
[super initializeData];
|
||||
|
||||
_maxVerticalFontScale = 2;
|
||||
_minVerticalFontScale = 1.3;
|
||||
_currentVerticalScale = _maxVerticalFontScale;
|
||||
self.cellWidthZoomEnabled = YES;
|
||||
self.cellWidthZoomScale = _maxVerticalFontScale;
|
||||
self.contentEdgeInsetLeft = 15;
|
||||
self.titleLabelZoomScale = _currentVerticalScale;
|
||||
self.titleLabelZoomEnabled = YES;
|
||||
self.selectedAnimationEnabled = YES;
|
||||
_maxVerticalCellSpacing = 20;
|
||||
_minVerticalCellSpacing = 10;
|
||||
self.cellSpacing = _maxVerticalCellSpacing;
|
||||
}
|
||||
|
||||
- (void)listDidScrollWithVerticalHeightPercent:(CGFloat)percent {
|
||||
CGFloat currentScale = [JXCategoryFactory interpolationFrom:self.minVerticalFontScale to:self.maxVerticalFontScale percent:percent];
|
||||
BOOL shouldReloadData = NO;
|
||||
if (self.currentVerticalScale != currentScale) {
|
||||
//有变化才允许reloadData
|
||||
shouldReloadData = YES;
|
||||
}
|
||||
self.currentVerticalScale = currentScale;
|
||||
self.cellWidthZoomScale = currentScale;
|
||||
self.cellSpacing = [JXCategoryFactory interpolationFrom:self.minVerticalCellSpacing to:self.maxVerticalCellSpacing percent:percent];
|
||||
if (shouldReloadData) {
|
||||
[self refreshDataSource];
|
||||
[self refreshState];
|
||||
[self.collectionView.collectionViewLayout invalidateLayout];
|
||||
[self.collectionView reloadData];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setCurrentVerticalScale:(CGFloat)currentVerticalScale {
|
||||
_currentVerticalScale = currentVerticalScale;
|
||||
|
||||
self.titleLabelZoomScale = currentVerticalScale;
|
||||
}
|
||||
|
||||
- (void)setMaxVerticalCellSpacing:(CGFloat)maxVerticalCellSpacing {
|
||||
_maxVerticalCellSpacing = maxVerticalCellSpacing;
|
||||
|
||||
self.cellSpacing = maxVerticalCellSpacing;
|
||||
}
|
||||
|
||||
- (void)setMaxVerticalFontScale:(CGFloat)maxVerticalFontScale {
|
||||
_maxVerticalFontScale = maxVerticalFontScale;
|
||||
|
||||
self.titleLabelZoomScale = maxVerticalFontScale;
|
||||
self.cellWidthZoomScale = maxVerticalFontScale;
|
||||
}
|
||||
|
||||
- (Class)preferredCellClass {
|
||||
return [JXCategoryTitleVerticalZoomCell class];
|
||||
}
|
||||
|
||||
- (void)refreshDataSource {
|
||||
NSMutableArray *tempArray = [NSMutableArray array];
|
||||
for (int i = 0; i < self.titles.count; i++) {
|
||||
JXCategoryTitleVerticalZoomCellModel *cellModel = [[JXCategoryTitleVerticalZoomCellModel alloc] init];
|
||||
[tempArray addObject:cellModel];
|
||||
}
|
||||
self.dataSource = tempArray;
|
||||
}
|
||||
|
||||
- (void)refreshCellModel:(JXCategoryBaseCellModel *)cellModel index:(NSInteger)index {
|
||||
[super refreshCellModel:cellModel index:index];
|
||||
|
||||
JXCategoryTitleVerticalZoomCellModel *model = (JXCategoryTitleVerticalZoomCellModel *)cellModel;
|
||||
model.maxVerticalFontScale = self.maxVerticalFontScale;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user