<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures">How do I make a UIButton wrap lines in the Title? Here is a sample code:</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffffff"> </span></p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(255, 255, 255); min-height: 13px;">
<span style="font-variant-ligatures: no-common-ligatures"></span><br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures"> func testing() {</span></p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures"> let aButton = UIButton(type: .system)</span></p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures"> aButton.lineWrap = true //How do I make aButton wrap lines?</span></p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures"> aButton.setTitle("123\n456\n789", for: .normal)</span></p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures"> self.view.addSubview(aButton)</span></p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures"> }</span></p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">
<span style="font-variant-ligatures: no-common-ligatures"></span><br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures">What I want to see is a button like this:</span></p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures"> ———</span></p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures">|123|</span></p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures">|456|</span></p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures">|789|</span></p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures"> ——-</span></p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">
<span style="font-variant-ligatures: no-common-ligatures"></span><br>
</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures">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 </span>can not find the proper syntax to code this.</p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;">
<span style="font-variant-ligatures: no-common-ligatures"></span><br>
</p>
<p></p>
<p style="margin-right: 0px; margin-left: 0px; font-size: 11px; line-height: normal; font-family: Menlo;">
<span style="font-variant-ligatures: no-common-ligatures">Thomas Cavalli</span></p>
</div>
</body>
</html>