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