美文网首页
UITableViewCell和UICollectionView

UITableViewCell和UICollectionView

作者: 超级卡布达 | 来源:发表于2019-05-16 12:45 被阅读0次

UITableView和UICollectionView想通,此处就已UITableView为例

UITableView自带自适应属性
        _tableView.rowHeight = UITableViewAutomaticDimension;
        _tableView.estimatedRowHeight = 130;
UITableViewCell中布局top和bottom需要布局,不然不会自适应
1.代码布局Masonry
        [commentContent mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.contentView).offset(kMarginLeftSpacing);
            make.right.mas_equalTo(self.contentView).offset(-kMarginLeftSpacing);
            //上面
            make.top.mas_equalTo(self.contentView).offset(kMarginTopSpacing);
        }];
       [userNum mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.contentView).offset(-10);
            make.top.mas_equalTo(line.mas_bottom).offset(0);
            //下面
            make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(0);
            make.height.mas_equalTo(43);
        }];
2.Autolayout布局
49FF058B-9D18-47A1-B580-04672CC5A8A2.png

label布局


image.png

button布局


image.png

备注:

如果有不足或者错误的地方还望各位读者批评指正,可以评论留言,笔者收到后第一时间回复。

QQ/微信:976971956/ljh976971956。

简书号:超级卡布达

感谢各位观众老爷的阅读,如果觉得笔者写的还凑合,可以关注或收藏一下,不定期分享一些好玩的实用的demo给大家。

文/超级卡布达(简书作者)

著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。

相关文章

网友评论

      本文标题:UITableViewCell和UICollectionView

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