Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Unified Diff: ui/ios/NSString+CrStringDrawing.h

Issue 704283002: [ui/ios] Add helper methods for getting the bounding size of some text. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/ios/NSString+CrStringDrawing.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/ios/NSString+CrStringDrawing.h
diff --git a/ui/ios/NSString+CrStringDrawing.h b/ui/ios/NSString+CrStringDrawing.h
index 330593ea9d1c91275b8f3874a19749ca4aa9ec9c..71228023a124701745d4f9c69d220918584880e5 100644
--- a/ui/ios/NSString+CrStringDrawing.h
+++ b/ui/ios/NSString+CrStringDrawing.h
@@ -9,6 +9,26 @@
@interface NSString (CrStringDrawing)
+// Calculates and returns the bounding rect for the receiver drawn using the
+// given size and font.
+// This method is implemented as a wrapper around
+// |boundingRectWithSize:options:attributes:context:| using the following values
+// for the parameters:
+// - size: the provided |size|
+// - options: NSStringDrawingUsesLineFragmentOrigin
+// - attributes: a NSDictionary with the provided |font|.
lpromero 2014/11/06 16:17:44 The period could go on the next line.
lliabraa 2014/11/06 16:35:47 Done.
+// - context: nil
+//
+// Note that the rect returned may contain fractional values.
lpromero 2014/11/06 16:17:43 What do you think of: +// Use |ceil| to raise the
lliabraa 2014/11/06 16:35:47 I've opted to return fractional values to keep the
+- (CGRect)cr_boundingRectWithSize:(CGSize)size
+ font:(UIFont*)font;
+
+// Convenience wrapper to just return the size of |boundingRectWithSize:font:|.
+//
+// Note that the size returned may contain fractional values.
lpromero 2014/11/06 16:17:44 Idem?
lliabraa 2014/11/06 16:35:47 Acknowledged.
+- (CGSize)cr_boundingSizeWithSize:(CGSize)size
+ font:(UIFont*)font;
+
// Returns the size of the string if it were to be rendered with the specified
// font on a single line. The width and height of the CGSize returned are
// pixel-aligned.
« no previous file with comments | « no previous file | ui/ios/NSString+CrStringDrawing.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698