Files
peko-ios/YuMi/Modules/YMNewHome/View/PIHoemCategoryTitleView.m
2024-02-26 17:18:21 +08:00

73 lines
2.2 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// 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