Retired Document
Important: This document may not represent best practices for current development. Links to downloads and other resources may no longer be valid.
Technical Q&A QA1051
How to measure CG text
Q: How do I measure the width of my text before drawing it with Core Graphics?
A: First call CGContextGetTextPosition to find the current text position. Then, set the text drawing mode to kCGTextInvisible using CGContextSetTextDrawingMode and draw the text. Finally, call CGContextGetTextPosition again to determine the final text position. Take the difference between the starting and ending positions to find the width of your text.
Document Revision History
Date | Notes |
---|---|
2007-08-02 | minor cleanup and made 'Not Recomended' |
2001-07-02 | New document that explains how to measure Core Graphics text. |
Copyright © 2007 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2007-08-02