Thursday, May 7, 2015

How to Wrap Text in a Monotouch/Xamarin UILabel

Doing some UI work on our iPhone app and still trying to remember what the UI supports.
I had an issue with how to wrap text in a UILabel field.  Fortunately, Xamarin forums has some great recipes.

What I needed was (UILineBreakMode.WordWrap)

Solution

var descriptionField = new UILabel(new RectangleF(10, 45, 300, 140));
descriptionField.LineBreakMode = UILineBreakMode.WordWrap;
descriptionField.Lines = 10;
descriptionField.BackgroundColor = UIColor.Gray;
Add(descriptionField);


Source:
http://developer.xamarin.com/recipes/ios/standard_controls/labels/uilabel-truncate-wrap-text/

No comments:

Post a Comment