// // RQVipReminderCell.m // jiaPei // // Created by 张嵘 on 2022/9/19. // Copyright © 2022 JCZ. All rights reserved. // #import "RQVipReminderCell.h" @interface RQVipReminderCell () @property (nonatomic, readwrite, strong) RQVipReminderItemViewModel *viewModel; @property (weak, nonatomic) IBOutlet YYTextView *oneLabel; @property (weak, nonatomic) IBOutlet YYTextView *twoLabel; @property (nonatomic, readwrite, strong) NSMutableAttributedString *spaceAttachment; @end @implementation RQVipReminderCell #pragma mark - PublicMethods + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath { static NSString *ID = @"RQVipReminderCell"; [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID]; RQVipReminderCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath]; if (!cell) cell = [self rq_viewFromXib]; [cell borderColor:RQColorFromHexString(@"#E0B279") width:1 cornorRadius:5]; return cell; } - (void)bindViewModel:(RQVipReminderItemViewModel *)viewModel { // @weakify(self) _viewModel = viewModel; } - (void)setIndexPath:(NSIndexPath *)indexPath rowsInSection:(NSInteger)rows { self.backgroundColor = RQColorFromHexString(@"#252531"); } #pragma mark - SystemMethods - (void)awakeFromNib { [super awakeFromNib]; _oneLabel.attributedText = [self dealStrWithAllStr:@"VIP题库主要面向 学习C1/C2的学员 进行编制,其他准驾车型的学员可根据自身需求购买!" str:@"学习C1/C2的学员" font:14]; _twoLabel.attributedText = [self dealStrWithAllStr:@"购买VIP课程是巩固培训成果, 将提升考试通过率 。" str:@"将提升考试通过率" font:13]; } #pragma mark - PrivateMethods - (NSMutableAttributedString *)dealStrWithAllStr:(NSString *)allStr str:(NSString *)str font:(NSInteger)font { NSMutableAttributedString *text = [NSMutableAttributedString new]; NSMutableAttributedString *testText = [NSMutableAttributedString new]; NSArray *allStrArr = [allStr componentsSeparatedByString:str]; NSMutableAttributedString *attrString1 = [[NSMutableAttributedString alloc] initWithString:allStrArr.firstObject]; attrString1.yy_font = [UIFont systemFontOfSize:font]; attrString1.yy_color = [UIColor qmui_colorWithHexString:@"#F8DEB8"]; [testText appendAttributedString: attrString1]; NSMutableAttributedString *typeAttachment = nil; QMUIButton *typeBtn = [QMUIButton buttonWithType:UIButtonTypeCustom]; CGFloat btnHeight = RQ_FIT_HORIZONTAL(22.f); CGFloat btnWeight = [str widthForFont:[UIFont systemFontOfSize:font]] + 8.f; CGFloat btnCornerRadius = 5; CGSize btnSize = CGSizeMake(btnWeight, btnHeight); typeBtn.size = btnSize; [typeBtn setTitle:str textColor:[UIColor qmui_colorWithHexString:@"#91540F"] Font:font fotState:UIControlStateNormal]; [typeBtn setBackgroundImage:[UIImage qmui_imageWithColor:[UIColor qmui_colorWithHexString:@"#F8DEB8"] size:btnSize cornerRadiusArray:@[@(btnCornerRadius), @(btnCornerRadius), @(btnCornerRadius), @(btnCornerRadius)]] forState:UIControlStateNormal]; typeAttachment = [NSMutableAttributedString yy_attachmentStringWithContent:typeBtn contentMode:UIViewContentModeCenter attachmentSize:btnSize alignToFont:[UIFont systemFontOfSize:font] alignment:YYTextVerticalAlignmentCenter]; [testText appendAttributedString:typeAttachment]; // [testText appendAttributedString:self.spaceAttachment]; NSMutableAttributedString *attrString2 = [[NSMutableAttributedString alloc] initWithString:allStrArr.lastObject]; attrString2.yy_font = [UIFont systemFontOfSize:font]; attrString2.yy_color = [UIColor qmui_colorWithHexString:@"#F8DEB8"]; [testText appendAttributedString: attrString2]; [text appendAttributedString:testText]; text.yy_lineSpacing = 8; return text; } - (NSMutableAttributedString *)spaceAttachment { if (!_spaceAttachment) { UIView *spaceView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 4, 25)]; _spaceAttachment = [NSMutableAttributedString yy_attachmentStringWithContent:spaceView contentMode:UIViewContentModeCenter attachmentSize:CGSizeMake(4, 25) alignToFont:[UIFont boldSystemFontOfSize:RQ_Exercise_Module.exerciseFontSize] alignment:YYTextVerticalAlignmentCenter]; } return _spaceAttachment; } @end