123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- //
- // ArticleTextCell.m
- // smartRhino
- //
- // Created by 潘洪波 on 2019/11/18.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "ArticleTextCell.h"
- #import "UILabel+Extension.h"
- @implementation ArticleTextCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (void)layoutSubviews{
- [super layoutSubviews];
- }
- - (void)setContent:(NSString *)content{
- _content = content;
-
- UIFont *font = [UIFont fontWithName:@"PingFang-SC-Regular" size:18];
- // NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
- // paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
- // paraStyle.alignment = NSTextAlignmentNatural;
- // paraStyle.lineSpacing = 1; //设置行间距
- // paraStyle.hyphenationFactor = 0.0;
- // paraStyle.firstLineHeadIndent = 30;
- // //设置字间距 NSKernAttributeName:@1.5f
- // NSDictionary *dic = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@(2)
- // };
- // NSAttributedString *attributeStr = [[NSAttributedString alloc] initWithString:content attributes:dic];
- //
- // self.contentLab.attributedText = attributeStr;
-
-
- self.contentLab.text = [self checkContent:content];
- [ZYCTool setLabel:self.contentLab withSpace:9 withFont:font setLineSpace:0 setTextSpace:0];
- self.contentLab.numberOfLines = 0;
- [self.contentLab sizeToFit];
-
- // self.contentLab.text = content;
- // self.contentLab.font = font;
- // self.contentLab.numberOfLines = 0;
- // [self.contentLab sizeToFit];
- }
- - (NSString *)checkContent:(NSString *)content
- {
- NSString *string = [content stringByReplacingOccurrencesOfString:@"<br>" withString:@"\n"];
- NSString *changeStr = [string stringByReplacingOccurrencesOfString:@" " withString:@" "];
- return changeStr;
- }
- + (CGFloat)cellHeight:(NSString *)text{
- UIFont *font = [UIFont fontWithName:@"PingFang-SC-Regular" size:18];
- // NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
- // paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
- // paraStyle.alignment = NSTextAlignmentNatural;
- // paraStyle.lineSpacing = 1; //设置行间距
- // paraStyle.hyphenationFactor = 0.0;
- // paraStyle.firstLineHeadIndent = 30;
- // //设置字间距 NSKernAttributeName:@1.5f
- // NSDictionary *dic = @{NSFontAttributeName:font, NSParagraphStyleAttributeName:paraStyle, NSKernAttributeName:@(2)};
- // NSString *tmpStr = [[self alloc] checkContent:text];
- CGSize size = [text sizeWithFont:font byWidth:SCREEN_WIDTH-24 textLineSpacing:9];
-
- // return size.height + 20 + 10;
- return size.height + 30 ;
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- @end
|