Skip to content

Instantly share code, notes, and snippets.

@smallmake
Last active August 29, 2015 14:22
Show Gist options
  • Save smallmake/db7b6d0f47258971fa4a to your computer and use it in GitHub Desktop.
Save smallmake/db7b6d0f47258971fa4a to your computer and use it in GitHub Desktop.
drawWithRectでTail Truncationする(ParagraphではなくRectで)
let style = NSMutableParagraphStyle()
style.lineBreakMode =.ByWordWrapping
style.alignment = NSTextAlignment.Left
let stringAttrubute = [
NSParagraphStyleAttributeName: style
]
let sampleText = "このStringは、このように...(略)...するようにしたい。途中で改行がはいるのである。\nどうすればいいのだろう?あ、できた!\nそして、まだまだStringは続く....(略)...."
sampleText.drawWithRect(
CGRectMake(0,0,800,300),
options: .UsesLineFragmentOrigin | .TruncatesLastVisibleLine,
attributes: stringAttrubute as [NSObject : AnyObject],
context: nil)
@smallmake
Copy link
Author

下記を参照してください。
http://qiita.com/smallmake/items/01838ea052e578225db2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment