我正在尝试制作适合屏幕的标签多线,所以我使用CGFloat.max使其高度动态...但使用CGFloat.max导致标签忽略定位,任何始终保持在Y轴的位置0 ....
即使传递任何变量甚至数字,也保持在Y轴上的0
有什么想法可以解决?
let label: UILabel = UILabel(frame: CGRectMake(10, 50, screenWidthArea, CGFloat.max))
label.numberOfLines = 0
label.lineBreakMode = NSLineBreakMode.ByWordWrapping
label.text = text
label.sizeToFit()
self.view.addSubview(label)
答案 0 :(得分:0)
Actually I've changed CGFloat.max to 0 and it worked well... Still no idea for the reason CGFloat.max locks the label on the top of screen.
let label: UILabel = UILabel(frame: CGRectMake(10, 50, screenWidthArea, 0))