123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- //
- // CourseDescAlertCell.m
- // KulexiuForStudent
- //
- // Created by 王智 on 2024/11/19.
- //
- #import "CourseDescAlertCell.h"
- @interface CourseDescAlertCell ()
- @property (weak, nonatomic) IBOutlet UILabel *tipsTitle;
- @property (weak, nonatomic) IBOutlet UILabel *tipsDesc;
- @end
- @implementation CourseDescAlertCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (void)configWithTitle:(NSString *)title desc:(NSString *)desc {
- self.tipsTitle.text = [NSString returnNoNullStringWithString:title];
-
- NSMutableParagraphStyle *paragraphStyle = [self getParagraphStyleWithFont:[UIFont systemFontOfSize:13.0f] lineHeight:22.0f];
- CGFloat baselineOffset = [self getBaseOffline:[UIFont systemFontOfSize:13.0f] lineHeight:22.0f];
- NSMutableAttributedString *attrs = [[NSMutableAttributedString alloc] initWithString:desc attributes:@{NSParagraphStyleAttributeName:paragraphStyle, NSBaselineOffsetAttributeName:@(baselineOffset),NSFontAttributeName:[UIFont systemFontOfSize:13.0f]}];
- self.tipsDesc.attributedText = attrs;
- }
- - (CGFloat)getBaseOffline:(UIFont *)font lineHeight:(CGFloat)lineHeight {
- CGFloat baselineOffset = (lineHeight - font.lineHeight) / 4;
- return baselineOffset;
- }
- - (NSMutableParagraphStyle *)getParagraphStyleWithFont:(UIFont *)font lineHeight:(CGFloat)lineHeigh {
- NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
- paragraphStyle.maximumLineHeight = lineHeigh;
- paragraphStyle.minimumLineHeight = lineHeigh;
- return paragraphStyle;
- }
- @end
|