Re: Non-breaking hyphen in UILabel?
Re: Non-breaking hyphen in UILabel?
- Subject: Re: Non-breaking hyphen in UILabel?
- From: Mark Woollard <email@hidden>
- Date: Fri, 24 Jan 2014 08:14:06 +0000
From [UILabel setLineBreakMode:] documentation:
If you are using styled text in iOS 6 or later, assigning a new value to this property causes the line break mode to be applied to the entirety of the string in the attributedTextproperty. If you want to apply the line break mode to only a portion of the text, create a new attributed string with the desired style information and associate it with the label. If you are not using styled text, this property applies to the entire text string in the text property.
So build an attributed string with no wrapping where you want to keep hyphenated words unbroken and assign to the labels attributedText property. Wrapping is property of NSParagraphStyle, set with NSParagraphStyleAttributeName attribute on the string.
Regards
Mark
On 24 Jan 2014, at 07:59, Rick Mann <email@hidden> wrote:
> I have a UILabel that breaks lines if the text gets too long. Traditionally, on the Mac, you could type an option-hyphen to get a non-breaking hyphen, but this still breaks (when I type option-hyphen in my source code file in Xcode).
>
> Is there a way to get a non-breaking hyphen in a UILabel?
>
> Thanks
>
> --
> Rick
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden