This commit is contained in:
2025-11-06 19:19:12 +08:00
parent a75afbe4c1
commit 6ba1339c0b
195 changed files with 13443 additions and 2729 deletions

View 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

View 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) {
//fonttitleLabelZoomScaletransform
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

View 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

View 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

View 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

View 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