zoukankan      html  css  js  c++  java
  • UITableViewCell的高度与UILabel自适应

    UITableViewCell内部只放了一个UILabel,Cell的高度随着UILabel内容的高度变化而变化,可重写UITableView的委托方法动态调整高度,还要设置UILabel.numberOfLines = 0

     override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
            if indexPath.row == 1 {
                //If it's content cell
                var boundSize = CGSizeMake(300, 500)
                var text = NSString(string: lblContent.text!)
                let attributes = NSDictionary(object: UIFont(name: "Arial", size: 15)!, forKey: NSFontAttributeName)
                let size = text.boundingRectWithSize(boundSize, options: NSStringDrawingOptions.UsesLineFragmentOrigin, attributes: attributes as [NSObject : AnyObject], context: nil)
                return size.height + 10
            } else {
                return 44
            }
        }
    
  • 相关阅读:
    SAP Easy tree
    SAP Column tree
    SAP Tree
    SAP 文本框多行输入
    SAP -SE30 程序运行时间分析
    SAP 实例- 页签tabsrip
    ABAP CDS
    ABAP CDS
    ABAP CDS
    ABAP CDS
  • 原文地址:https://www.cnblogs.com/foxting/p/4600573.html
Copyright © 2011-2022 走看看