I would like to add a label to table footer which will auto increase and footer height also auto increases .How can I achieve this any ideas
Asked
Active
Viewed 318 times
-1
-
This was in answer to another issue, but it solves the table footer auto-sizing as well: https://stackoverflow.com/a/46414131/6257435 – DonMag Oct 04 '17 at 19:51
-
Please show the code you've written and we can help you see where you're going wrong. To encourage people to help you, you show that you've _tried_ to help yourself. – Ashley Mills Nov 02 '17 at 10:18
1 Answers
0
In general you need to calculate the height of text in the UILabel.
let messageTextSize = text.boundingRect(with: CGSize.init(width: dialogViewWidth, height: CGFloat(MAXFLOAT)), options: .usesLineFragmentOrigin, context: nil)
and then you set label frame to have height / width correspond to text
let textLabel = UILabel()
textLabel.frame = CGRect.init(x: sidePadding, y: titleLabel.frame.origin.y + titleLabel.frame.size.height, width: dialogViewWidth - 2 * sidePadding, height:messageTextSize.height)
you would usually do in view's layoutSubview

Irfan
- 432
- 1
- 6
- 17