gsdios / SDAutoLayout

One line of code to implement automatic layout. 一行代码搞定自动布局!支持Cell和Tableview高度自适应,Label和ScrollView内容自适应,致力于做最简单易用的AutoLayout库。The most easy way for autoLayout. Based on runtime.
MIT License
5.9k stars 1.28k forks source link

cell里的label行间距不正确 #200

Closed DJSubj closed 7 years ago

DJSubj commented 7 years ago

我设置了label的isAttributedContent为YES,行间距设置为10,一部分cell只有一行文字,一部分cell多行文字,问题是:一行文字的cell,第一个cell布局正确,后面的其它的cell高度都会加上一个行间距;多行文字的cell布局没毛病

gsdios commented 7 years ago

代码贴出来下

DJSubj commented 7 years ago

@gsdios

_descLab = [UILabel labelWithFont:15.0 TextColor:DJ_BLACK_COLOR Text:@""]; _descLab.numberOfLines = 0; _descLab.isAttributedContent = YES;

_descLab.sd_layout .leftSpaceToView(_titleLab, 10) .topSpaceToView(self.contentView, 15) .rightSpaceToView(self.contentView, 15) .autoHeightRatio(0);

[self setupAutoHeightWithBottomView:_descLab bottomMargin:15];

NSMutableParagraphStyle paragraph = [[NSMutableParagraphStyle alloc] init]; paragraph.lineSpacing = 10;//行间距 NSMutableAttributedString attr = [[NSMutableAttributedString alloc] initWithString:model.desc]; [attr addAttribute:NSParagraphStyleAttributeName value:paragraph range:NSMakeRange(0, model.desc.length)]; _descLab.attributedText = attr;

wechatimg46

luo-h commented 5 years ago

我也是这个问题,设置行间距,如果是多行的话正确,如果只有一行则文字距离顶部有一段距离

CaiChenghan commented 5 years ago

@DJSubj 同样的问题,label设置了自定义行间距后,单行显示会多一个行高度;多行显示却没有,这是一个bug。