Replacement for deprecated sizeWithFont: in iOS 7?

后端 未结 20 979
难免孤独
难免孤独 2020-11-22 08:49

In iOS 7, sizeWithFont: is now deprecated. How do I now pass in the UIFont object into the replacement method sizeWithAttributes:?

20条回答
  •  盖世英雄少女心
    2020-11-22 09:10

    Better use automatic dimensions (Swift):

      tableView.estimatedRowHeight = 68.0
      tableView.rowHeight = UITableViewAutomaticDimension
    

    NB: 1. UITableViewCell prototype should be properly designed (for the instance don't forget set UILabel.numberOfLines = 0 etc) 2. Remove HeightForRowAtIndexPath method

    enter image description here

    VIDEO: https://youtu.be/Sz3XfCsSb6k

提交回复
热议问题