Re: [SOLVED] -[drawInRect:withFont:] in Image Context?
Re: [SOLVED] -[drawInRect:withFont:] in Image Context?
- Subject: Re: [SOLVED] -[drawInRect:withFont:] in Image Context?
- From: Rick Mann <email@hidden>
- Date: Tue, 24 May 2011 18:05:35 -0700
Ugh. My font was bad. Sorry for the noise.
On May 24, 2011, at 17:58 , Rick Mann wrote:
> 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
_______________________________________________
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