[swift-users] How do I word wrap a UIButton title in code?

Adrian Zubarev adrian.zubarev at devandartist.com
Fri Jan 27 18:15:32 CST 2017


If I remember correctly the property on the UIButton is called `.lineBreakMode`, which accepts an enum.  

--  
Adrian Zubarev
Sent with Airmail  

Am 28. Januar 2017 um 00:46:18, Mutlu Qwerty via swift-users (swift-users at swift.org(mailto:swift-users at swift.org)) schrieb:

>  
>  
> How do I make a UIButton wrap lines in the Title? Here is a sample code:  
>  
>  
>  
>  
>  
>  
> func testing() {
>  
>  
> let aButton = UIButton(type: .system)
>  
>  
> aButton.lineWrap = true //How do I make aButton wrap lines?
>  
>  
> aButton.setTitle("123\n456\n789", for: .normal)
>  
>  
> self.view.addSubview(aButton)
>  
>  
> }
>  
>  
>  
>  
>  
>  
> What I want to see is a button like this:
>  
>  
> ———
>  
>  
> |123|
>  
>  
> |456|
>  
>  
> |789|
>  
>  
> ——-
>  
>  
>  
>  
>  
>  
> This can be done in the Storyboard by selecting “Word Wrap” in the Button’s Control - Line Break attribute. But I am creating my UIButtons in code and can not find the proper syntax to code this.
>  
>  
>  
>  
>  
>  
>  
>  
>  
> Thomas Cavalli
>  
>  
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170128/b1f63357/attachment.html>


More information about the swift-users mailing list