• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting exact height of NSAttributedString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting exact height of NSAttributedString


  • Subject: Re: Getting exact height of NSAttributedString
  • From: "Shawn Erickson" <email@hidden>
  • Date: Fri, 21 Apr 2006 08:42:00 -0700

As an FYI using the following hack-ish code I can get size of the
drawn text including any text wrapping, etc. that may have taken place
based on attributes. Note I still haven't gotten -[NSAttributedString
boundingRectWithSize:options:] to work so that question is still
outstanding...

NSTextView* tmpView = [[NSTextView alloc] initWithFrame:[textField frame]];
[[tmpView textStorage] setAttributedString:[textField attributedStringValue]];
[tmpView setHorizontallyResizable:NO];
[tmpView sizeToFit];
NSLog(@"Before:%@, After:%@",
    NSStringFromRect([textField frame]),
    NSStringFromRect([tmpView frame]))

2006-04-21 08:32:22.428 XX[3060] Before:{{0, 11}, {317, 28}},
After:{{0, 11}, {317, 28}}
2006-04-21 08:32:27.312 XX[3060] Before:{{0, 11}, {317, 28}},
After:{{0, 11}, {317, 117}}
2006-04-21 08:32:52.458 XX[3060] Before:{{0, 11}, {317, 28}},
After:{{0, 11}, {317, 65}}

-Shawn
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Getting exact height of NSAttributedString (From: "Shawn Erickson" <email@hidden>)

  • Prev by Date: Modify NSMenu font
  • Next by Date: Trying to read PICT data using Quartz functions
  • Previous by thread: Re: Getting exact height of NSAttributedString
  • Next by thread: Re: Getting exact height of NSAttributedString
  • Index(es):
    • Date
    • Thread