more about NSAttributedString and truncation in iOS 6
more about NSAttributedString and truncation in iOS 6
- Subject: more about NSAttributedString and truncation in iOS 6
- From: Matt Neuburg <email@hidden>
- Date: Sat, 26 Jan 2013 09:20:09 -0800
I suppose no one remembers this:
http://www.cocoabuilder.com/archive/cocoa/323722-nsattributedstring-mysteriously-truncated-too-soon.html
Anyhow, I have finally realized after all this time that what I was seeing here was in fact the _standard_ behavior of NSAttributedString under iOS 6. If an NSAttributedString's paragraph style includes a `lineBreakMode` of `NSLineBreakByTruncatingTail`, and if that string is going to wrap in the width within which it is being drawn, then only the _first_ line is drawn (truncated).
The reason this confused me is that it isn't what I was expecting. It isn't what I was expecting because UILabel's truncation works (and always has worked) a different way: its `lineBreakMode` applied to a multiline string draws the _whole_ string, wrapping, as much as will fit in the full height of the label, and _then_ truncates the _last_ line.
So what we have now is that NSParagraphStyle and UILabel both have a `lineBreakMode` that can have a value of `NSLineBreakByTruncatingTail`, but they implement it very differently. (That is why I ended up having to achieve the same end using the NSAttributedString drawing option `NSStringDrawingTruncatesLastVisibleLine`.) Just wanted to make that perfectly clear for generations to come... :) m.
--
matt neuburg, phd = email@hidden, http://www.apeth.net/matt/
pantes anthropoi tou eidenai oregontai phusei
Programming iOS 5! http://shop.oreilly.com/product/0636920023562.do
RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
TidBITS, Mac news and reviews since 1990, http://www.tidbits.com
_______________________________________________
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