Reputation: 25
I need to adjust the size of the UILabel according to its size dynamically, width may be constant but height should be dynamic
Upvotes: 1
Views: 70
Reputation: 552
let label:UILabel = UILabel(frame: CGRect(x: 30, y: 0, width: curWidth!, height: CGFloat.greatestFiniteMagnitude))
label.numberOfLines = 0
label.lineBreakMode = NSLineBreakMode.byWordWrapping
label.font = curFont!
label.sizeToFit();
Upvotes: 3