2023-09-01 18:58:41 +08:00
|
|
|
|
//
|
|
|
|
|
// PIHoemCategoryTitleView.m
|
|
|
|
|
// YuMi
|
|
|
|
|
//
|
|
|
|
|
// Created by duoban on 2023/9/1.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "PIHoemCategoryTitleView.h"
|
2024-02-22 15:58:48 +08:00
|
|
|
|
#import "PIHoemCategoryTitleCell.h"
|
|
|
|
|
#import "PIHoemCategoryCollectionView.h"
|
|
|
|
|
@interface PIHoemCategoryTitleView()<PIHoemCategoryCollectionViewDelegate>
|
|
|
|
|
|
|
|
|
|
@property(nonatomic,strong) PIHoemCategoryCollectionView *pi_collectionView;
|
2023-09-01 18:58:41 +08:00
|
|
|
|
@end
|
|
|
|
|
@implementation PIHoemCategoryTitleView
|
|
|
|
|
-(instancetype)initWithFrame:(CGRect)frame{
|
|
|
|
|
self = [super initWithFrame:frame];
|
|
|
|
|
if(self){
|
|
|
|
|
[self installUI];
|
|
|
|
|
[self installConstraints];
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
-(void)installUI{
|
2024-02-22 15:58:48 +08:00
|
|
|
|
[self addSubview:self.pi_collectionView];
|
2023-09-01 18:58:41 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
-(void)installConstraints{
|
|
|
|
|
|
2024-02-22 15:58:48 +08:00
|
|
|
|
[self.pi_collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.edges.equalTo(self);
|
2023-09-01 18:58:41 +08:00
|
|
|
|
}];
|
|
|
|
|
}
|
2024-02-22 15:58:48 +08:00
|
|
|
|
-(void)setTitleList:(NSMutableArray *)titleList{
|
|
|
|
|
_titleList = titleList;
|
|
|
|
|
self.pi_collectionView.titleList = titleList;
|
|
|
|
|
}
|
2023-09-25 16:02:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)setIndex:(NSInteger)index{
|
2023-09-01 18:58:41 +08:00
|
|
|
|
_index = index;
|
2024-02-22 15:58:48 +08:00
|
|
|
|
self.pi_collectionView.index = _index;
|
2023-09-01 18:58:41 +08:00
|
|
|
|
}
|
2024-02-22 15:58:48 +08:00
|
|
|
|
#pragma mark - PIHoemCategoryCollectionViewDelegate
|
2024-02-26 17:18:21 +08:00
|
|
|
|
- (void)pi_didSelectItemAtIndex:(NSInteger)index{
|
2024-02-22 15:58:48 +08:00
|
|
|
|
if(self.scrolledHandle){
|
|
|
|
|
self.scrolledHandle(index);
|
2023-09-01 18:58:41 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-02-22 15:58:48 +08:00
|
|
|
|
#pragma mark - 懒加载
|
|
|
|
|
- (PIHoemCategoryCollectionView *)pi_collectionView{
|
|
|
|
|
if (!_pi_collectionView) {
|
|
|
|
|
|
|
|
|
|
_pi_collectionView = [[PIHoemCategoryCollectionView alloc] initWithFrame:CGRectZero ];
|
|
|
|
|
_pi_collectionView.delegate = self;
|
2023-09-01 18:58:41 +08:00
|
|
|
|
|
|
|
|
|
}
|
2024-02-22 15:58:48 +08:00
|
|
|
|
return _pi_collectionView;
|
2023-09-01 18:58:41 +08:00
|
|
|
|
}
|
|
|
|
|
//- (void)layoutSubviews{
|
|
|
|
|
// [super layoutSubviews];
|
|
|
|
|
//
|
|
|
|
|
// //部分使用者为了适配不同的手机屏幕尺寸,JXCategoryView的宽高比要求保持一样,所以它的高度就会因为不同宽度的屏幕而不一样。计算出来的高度,有时候会是位数很长的浮点数,如果把这个高度设置给UICollectionView就会触发内部的一个错误。所以,为了规避这个问题,在这里对高度统一向下取整。
|
|
|
|
|
// //如果向下取整导致了你的页面异常,请自己重新设置JXCategoryView的高度,保证为整数即可。
|
|
|
|
|
//
|
|
|
|
|
// CGRect targetFrame = CGRectMake(0, 0, self.bounds.size.width - kGetScaleWidth(159), floor(self.bounds.size.height));
|
2024-02-22 15:58:48 +08:00
|
|
|
|
// self.pi_collectionView.frame = targetFrame;
|
2023-09-01 18:58:41 +08:00
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
@end
|