Swift tableViewCell 高度自适应

 static func cellhight (content: String) -> CGFloat {

        let rect: CGRect = content.boundingRectWithSize(
            CGSizeMake(SCREENWIDTH - 20, 0),
            options: NSStringDrawingOptions.UsesLineFragmentOrigin,
            attributes: [NSFontAttributeName:
            UIFont.systemFontOfSize(14)],
            context: nil)
    
        return rect.height + 61
    }

在返回cell 的高度的方法中直接调用
return TableViewCell.cellhight("这里面填想要自适应的文字")

你可能感兴趣的:(Swift tableViewCell 高度自适应)