-[drawInRect:withFont:] in Image Context?
-[drawInRect:withFont:] in Image Context?
- Subject: -[drawInRect:withFont:] in Image Context?
- From: Rick Mann <email@hidden>
- Date: Tue, 24 May 2011 17:58:32 -0700
I'm trying to do this:
CGSize imgSize = CGSizeMake(25.0f, 25.0f);
UIGraphicsBeginImageContext(imgSize);
NSString* s = [NSString stringWithFormat: @"%u", ga.stations.count];
CGRect r = CGRectMake(0.0f, 0.0f, imgSize.width, imgSize.height);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(ctx, [UIColor redColor].CGColor);
CGContextFillRect(ctx, r);
[[UIColor whiteColor] set];
UIFont* f = [UIFont fontWithName: @"Helvetica-Neue" size: 15.0f];
CGSize ss = [s sizeWithFont: f];
[s drawInRect: r withFont: f lineBreakMode: UILineBreakModeClip alignment: UITextAlignmentCenter];
UIImage* img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
The reported size in "ss" is 0,0, and nothing draws. The red rectangle does draw, though.
I'm guessing UIKit routines can't be used in an image context, but I didn't see that spelled out in the method docs.
--
Rick
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden