|
@@ -30,6 +30,27 @@
|
|
return view;
|
|
return view;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+- (void)configTitle:(NSString *)title content:(NSString *)content {
|
|
|
|
+ self.titleCount.text = [NSString stringWithFormat:@"%zd/25",title.length];
|
|
|
|
+ self.contentCount.text = [NSString stringWithFormat:@"%zd/200",content.length];
|
|
|
|
+
|
|
|
|
+ self.topTipsLabel.hidden = [NSString isEmptyString:title] ? NO : YES;
|
|
|
|
+ self.tipsLabel.hidden = [NSString isEmptyString:content] ? NO : YES;
|
|
|
|
+
|
|
|
|
+ NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
|
|
|
|
+ paragraphStyle.lineSpacing = 4.0f;
|
|
|
|
+ UIFont *font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
|
|
|
|
+ if (![NSString isEmptyString:title]) {
|
|
|
|
+ NSDictionary *attributes = @{NSFontAttributeName:font,NSParagraphStyleAttributeName:paragraphStyle,NSForegroundColorAttributeName:HexRGB(0x333333)};
|
|
|
|
+ self.titleView.attributedText = [[NSAttributedString alloc] initWithString:title attributes:attributes];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (![NSString isEmptyString:content]) {
|
|
|
|
+ NSDictionary *attributes = @{NSFontAttributeName:font,NSParagraphStyleAttributeName:paragraphStyle,NSForegroundColorAttributeName:HexRGB(0x333333)};
|
|
|
|
+ self.contentArea.attributedText = [[NSAttributedString alloc] initWithString:content attributes:attributes];
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
- (void)publishCallback:(PublishBlock)callback {
|
|
- (void)publishCallback:(PublishBlock)callback {
|
|
if (callback) {
|
|
if (callback) {
|
|
self.callback = callback;
|
|
self.callback = callback;
|
|
@@ -106,6 +127,21 @@
|
|
return YES;
|
|
return YES;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+- (void)updateTextViewLineHeight:(UITextView *)textView {
|
|
|
|
+ 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:HexRGB(0x333333)}];
|
|
|
|
+ textView.attributedText = attrs;
|
|
|
|
+ textView.selectedRange = selectedRange;
|
|
|
|
+ [UIView setAnimationsEnabled:YES];
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+- (void)textViewDidChange:(UITextView *)textView {
|
|
|
|
+ [self updateTextViewLineHeight:textView];
|
|
|
|
+}
|
|
|
|
|
|
- (BOOL)textViewShouldEndEditing:(UITextView *)textView {
|
|
- (BOOL)textViewShouldEndEditing:(UITextView *)textView {
|
|
[self endEditing:YES];
|
|
[self endEditing:YES];
|