Skip to content

Commit 30c10fe

Browse files
committed
chore(ios): useful methods
1 parent 076b03c commit 30c10fe

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/ui-canvas/platforms/ios/src/Drawing-Text.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ UIFont *FontForWrappedString(NSString *string, NSString *fontFace, CGRect rect,
3636
+ (void) drawAttributedStringInRect: (NSAttributedString *)string x:(CGFloat)x y:(CGFloat)y width:(CGFloat)width height:(CGFloat)height font:(UIFont*)font alignment:(NSTextAlignment)alignment color:(UIColor*)color;
3737
+ (void) drawString: (NSString *)string x:(CGFloat)x y:(CGFloat)y withAttributes:(NSDictionary*)attributes;
3838
+ (void) drawAttributedString: (NSAttributedString *)string x:(CGFloat)x y:(CGFloat)y withAttributes:(NSDictionary*)attributes;
39+
+ (void) drawAttributedString: (NSAttributedString *)string x:(CGFloat)x y:(CGFloat)y width:(CGFloat)width height:(CGFloat)height withAttributes:(NSDictionary*)attributes;
3940
+ (CGRect)getTextBounds:(NSString*)text from:(NSUInteger)from to:(NSUInteger)to attributes:(NSDictionary*)attributes;
4041
+ (CGFloat)measureText:(NSString*)text from:(NSUInteger)from to:(NSUInteger)to attributes:(NSDictionary*)attributes;
4142
@end

packages/ui-canvas/platforms/ios/src/Drawing-Text.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ void DrawAttributedStringInRectWithAttrs(NSAttributedString *string, CGRect rect
119119
NSRange range = NSMakeRange(0, string.length);
120120
[attributedString addAttributes:attributes range:range];
121121

122-
CGRect destRect = [string boundingRectWithSize:CGSizeMake(rect.size.width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin context:nil];
123-
CGRect outputRect = RectCenteredInRect(destRect, rect);
124-
[attributedString drawInRect:outputRect];
122+
// CGRect destRect = [string boundingRectWithSize:CGSizeMake(rect.size.width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading context:nil];
123+
// CGRect outputRect = RectCenteredInRect(destRect, rect);
124+
[attributedString drawWithRect:rect options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading context:nil] ;
125125
}
126126

127127
#pragma mark - Unwrapped
@@ -286,6 +286,9 @@ + (void) drawString: (NSString *)string x:(CGFloat)x y:(CGFloat)y withAttributes
286286
+ (void) drawAttributedString: (NSAttributedString *)string x:(CGFloat)x y:(CGFloat)y withAttributes:(NSDictionary*)attributes{
287287
DrawAttributedStringAtPosWithAttrs(string, x, y, attributes);
288288
}
289+
+ (void) drawAttributedString: (NSAttributedString *)string x:(CGFloat)x y:(CGFloat)y width:(CGFloat)width height:(CGFloat)height withAttributes:(NSDictionary*)attributes {
290+
DrawAttributedStringInRectWithAttrs(string, CGRectMake (x, y, width, height), attributes);
291+
}
289292

290293
+ (CGRect)getTextBounds:(NSString*)text from:(NSUInteger)from to:(NSUInteger)to attributes:(NSDictionary*)attributes {
291294

0 commit comments

Comments
 (0)