Steven 7 月之前
父節點
當前提交
3d1c3aa61f

+ 11 - 12
KulexiuForTeacher/KulexiuForTeacher/Module/Course/View/CourseGroupView/CourseGroupPlanAlertView.m

@@ -31,6 +31,15 @@
     self.bgView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
 }
 
+- (NSDictionary *)getTypeAttributes {
+    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
+    paragraphStyle.lineSpacing = 4.0f;
+    UIFont *font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
+    
+    NSDictionary *attributes = @{NSFontAttributeName:font,NSParagraphStyleAttributeName:paragraphStyle,NSForegroundColorAttributeName:HexRGBAlpha(0x000000, 0.9)};
+    return attributes;
+}
+
 + (instancetype)sharedInstance {
     CourseGroupPlanAlertView *view = [[[NSBundle mainBundle] loadNibNamed:@"CourseGroupPlanAlertView" owner:nil options:nil] firstObject];
     return view;
@@ -42,14 +51,7 @@
     }
     self.countLabel.text = [NSString stringWithFormat:@"%zd/500",planString.length];
     self.tipsLabel.hidden = [NSString isEmptyString:planString] ? NO : YES;
-    
-    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
-    paragraphStyle.lineSpacing = 4.0f;
-    UIFont *font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
-    
-    NSDictionary *attributes = @{NSFontAttributeName:font,NSParagraphStyleAttributeName:paragraphStyle,NSForegroundColorAttributeName:HexRGBAlpha(0x000000, 0.9)};
-    
-        self.textView.attributedText = [[NSAttributedString alloc] initWithString:planString attributes:attributes];
+    self.textView.attributedText = [[NSAttributedString alloc] initWithString:planString attributes:[self getTypeAttributes]];
 }
 
 - (void)showInView:(UIView *)displayView {
@@ -113,12 +115,9 @@
         // 当前处于拼音输入状态,暂不更新 attributedText
         return;
     }
-    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
-    paragraphStyle.lineSpacing = 4.0f;
-    UIFont *font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
     [UIView setAnimationsEnabled:NO];
     NSRange selectedRange = textView.selectedRange;
-    NSMutableAttributedString *attrs = [[NSMutableAttributedString alloc] initWithString:textView.text attributes:@{NSParagraphStyleAttributeName:paragraphStyle,NSFontAttributeName:font, NSForegroundColorAttributeName:HexRGBAlpha(0x000000, 0.9)}];
+    NSMutableAttributedString *attrs = [[NSMutableAttributedString alloc] initWithString:textView.text attributes:[self getTypeAttributes]];
     textView.attributedText = attrs;
     textView.selectedRange = selectedRange;
     [UIView setAnimationsEnabled:YES];