// // NYChartMatrixView.m // NYChartDemo // // Created by kgj on 2023/3/17. // #import "NYChartMatrixView.h" #import "NYChartMatrixViewCell.h" @interface NYChartMatrixView () { bool _isLoad; } //内容view @property (nonatomic,weak) UIView *contentView; @property (nonatomic,weak) UIScrollView *mScrollView; @property (nonatomic,weak) UIButton *currentBtn; @end @implementation NYChartMatrixView #pragma mark --UI - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self setupUI]; } return self; } - (instancetype)initWithCoder:(NSCoder *)decoder { self = [super initWithCoder:decoder]; if (self) { [self setupUI]; } return self; } - (void)setupUI { // self.backgroundColor = UIColor.yellowColor; UIScrollView *mScrollView = [[UIScrollView alloc] init]; [self addSubview:mScrollView]; self.mScrollView = mScrollView; [mScrollView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.mas_equalTo(self); make.left.mas_equalTo(self).offset(0); make.right.mas_equalTo(self).offset(0); }]; UIView *contentView = [[UIView alloc] init]; contentView.mj_w = 200.f; [mScrollView addSubview:contentView]; self.contentView = contentView; // [contentView mas_makeConstraints:^(MASConstraintMaker *make) { // make.top.bottom.mas_equalTo(self); // make.left.mas_equalTo(self).offset(0); // make.right.mas_equalTo(self).offset(0); // }]; } - (void)layoutSubviews { [super layoutSubviews]; } #pragma mark --NYBaseChartViewDelegate - (void)loadView { if(!_isLoad){ _isLoad = YES; /** 333 333 333 333 333 333 333 333 */ if(self.dataSource.count){ NSInteger totalloc = 10;//总列 CGFloat itemW = floorf(KRealValue(20)); CGFloat itemH = floorf(KRealValue(22)); CGFloat margin = 0.5; for (int i=0; i