美文网首页iOS技术点
iOS 使用SDAutoLayout实现控件根据内容进行宽度自适

iOS 使用SDAutoLayout实现控件根据内容进行宽度自适

作者: 达_Ambition | 来源:发表于2018-05-23 16:55 被阅读279次

参考文档:使用SDAutoLayout实现控件根据内容进行宽度自适应和高度自适应

举例,让label高度自适应

    contentLabel =[[UILabel alloc]init];
    [contentScroll addSubview:contentLabel];      
    //第一步:autoHeightRatio(0)
    contentLabel.sd_layout.leftEqualToView(contentScroll).topEqualToView(contentScroll).rightEqualToView(contentScroll).autoHeightRatio(0);
    //第二步:
    [self.view setupAutoHeightWithBottomView:contentLabel bottomMargin:0];

相关文章

网友评论

    本文标题:iOS 使用SDAutoLayout实现控件根据内容进行宽度自适

    本文链接:https://www.haomeiwen.com/subject/kiarjftx.html