Ios 带SWIFT的3行单独的UIButton标题

Ios 带SWIFT的3行单独的UIButton标题,ios,swift,button,uibutton,multiline,Ios,Swift,Button,Uibutton,Multiline,我一直试图用swift编码UIButton,我想让按钮上的文本显示三行。这是我到目前为止的代码,但是它不显示超过三行,字体的大小也不起作用。不知道我哪里出错了。非常感谢你的建议 button.titleLabel!.text = "Line1 Line2 Line3" button.titleLabel!.font = UIFont(name: "MarkerFelt-Thin", size: 45) button.titleLabel!.textColor = UIColor.whiteCol

我一直试图用swift编码UIButton,我想让按钮上的文本显示三行。这是我到目前为止的代码,但是它不显示超过三行,字体的大小也不起作用。不知道我哪里出错了。非常感谢你的建议

button.titleLabel!.text = "Line1 Line2 Line3"
button.titleLabel!.font = UIFont(name: "MarkerFelt-Thin", size: 45)
button.titleLabel!.textColor = UIColor.whiteColor()
button.titleLabel!.textAlignment = .Center
button.titleLabel!.numberOfLines = 3
button.titleLabel!.frame = CGRectMake(15, 54, 300, 500)
button.titleLabel!.lineBreakMode = .ByWordWrapping

谢谢

试试:
按钮。标题标签!。text=“Line1\nLine2\nLine3”
使用
\n
将给您换行符。我似乎无法让换行符正常工作。我把它写进代码里了,但还是在同一行?