OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GFX_IOS_NSSTRING_CR_STRING_DRAWING_H_ | 5 #ifndef UI_GFX_IOS_NSSTRING_CR_STRING_DRAWING_H_ |
6 #define UI_GFX_IOS_NSSTRING_CR_STRING_DRAWING_H_ | 6 #define UI_GFX_IOS_NSSTRING_CR_STRING_DRAWING_H_ |
7 | 7 |
8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
9 | 9 |
10 @interface NSString (CrStringDrawing) | 10 @interface NSString (CrStringDrawing) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // 7 in favor of -sizeWithAttributes:. Specifically, this method will return | 43 // 7 in favor of -sizeWithAttributes:. Specifically, this method will return |
44 // CGSizeZero if |font| is nil, and the width and height returned are rounded up | 44 // CGSizeZero if |font| is nil, and the width and height returned are rounded up |
45 // to integer values. | 45 // to integer values. |
46 // TODO(lliabraa): This method was added to ease the transition off of the | 46 // TODO(lliabraa): This method was added to ease the transition off of the |
47 // deprecated sizeWithFont: method. New call sites should not be added and | 47 // deprecated sizeWithFont: method. New call sites should not be added and |
48 // existing call sites should be audited to determine the correct behavior for | 48 // existing call sites should be audited to determine the correct behavior for |
49 // nil |font| and rounding, then replaced with cr_pixelAlignedSizeWithFont: or | 49 // nil |font| and rounding, then replaced with cr_pixelAlignedSizeWithFont: or |
50 // sizeWithAttributes: (crbug.com/364419). | 50 // sizeWithAttributes: (crbug.com/364419). |
51 - (CGSize)cr_sizeWithFont:(UIFont*)font; | 51 - (CGSize)cr_sizeWithFont:(UIFont*)font; |
52 | 52 |
| 53 // If |index| is 0, returns an empty string. |
| 54 // If |index| is >= than self.length, returns self. |
| 55 // Otherwise, returns string cut to have |index| characters with an |
| 56 // ellipsis at the end. |
| 57 - (NSString*)cr_stringByCuttingToIndex:(NSUInteger)index; |
| 58 |
| 59 // Returns an elided version of string that fits in |bounds|. |
| 60 // System font of Label size is used for determining the string drawing size. |
| 61 - (NSString*)cr_stringByElidingToFitSize:(CGSize)bounds; |
| 62 |
53 @end | 63 @end |
54 | 64 |
55 #endif // UI_GFX_IOS_NSSTRING_CR_STRING_DRAWING_H_ | 65 #endif // UI_GFX_IOS_NSSTRING_CR_STRING_DRAWING_H_ |
OLD | NEW |