|
@@ -74,8 +74,8 @@
|
|
|
if ([NSString isEmptyString:planDesc]) {
|
|
|
planDesc = @"暂无课程规划";
|
|
|
}
|
|
|
- NSMutableParagraphStyle *paragraphStyle = [GroupCourseListCell getParagraphStyleWithFont:[UIFont systemFontOfSize:13.0f] lineHeight:22.0f];
|
|
|
- CGFloat baselineOffset = [GroupCourseListCell getBaseOffline:[UIFont systemFontOfSize:13.0f] lineHeight:22.0f];
|
|
|
+ NSMutableParagraphStyle *paragraphStyle = [GroupCourseListCell getParagraphStyleWithFont:[UIFont systemFontOfSize:13.0f] lineHeight:20.0f];
|
|
|
+ CGFloat baselineOffset = [GroupCourseListCell getBaseOffline:[UIFont systemFontOfSize:13.0f] lineHeight:20.0f];
|
|
|
NSMutableAttributedString *attrs = [[NSMutableAttributedString alloc] initWithString:planDesc attributes:@{NSParagraphStyleAttributeName:paragraphStyle, NSBaselineOffsetAttributeName:@(baselineOffset),NSFontAttributeName:[UIFont systemFontOfSize:13.0f], NSForegroundColorAttributeName:HexRGB(0x777777)}];
|
|
|
self.coursPlanLabel.attributedText = attrs;
|
|
|
}
|
|
@@ -164,8 +164,11 @@
|
|
|
}
|
|
|
|
|
|
+ (CGFloat)getBaseOffline:(UIFont *)font lineHeight:(CGFloat)lineHeight {
|
|
|
- CGFloat baselineOffset = (lineHeight - font.lineHeight) / 4;
|
|
|
- return baselineOffset;
|
|
|
+ CGFloat descender = fabs(font.descender); // descender 为负值,取绝对值
|
|
|
+ CGFloat ascender = font.ascender;
|
|
|
+ CGFloat fontHeight = ascender + descender;
|
|
|
+ CGFloat offset = (lineHeight - fontHeight) / 2.0; // 假设上下均等分布
|
|
|
+ return offset;
|
|
|
}
|
|
|
|
|
|
+ (NSMutableParagraphStyle *)getParagraphStyleWithFont:(UIFont *)font lineHeight:(CGFloat)lineHeigh {
|