• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
-[drawInRect:withFont:] in Image Context?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

-[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

  • Follow-Ups:
    • Re: [SOLVED] -[drawInRect:withFont:] in Image Context?
      • From: Rick Mann <email@hidden>
  • Prev by Date: Re: encoding of file names
  • Next by Date: Re: [SOLVED] -[drawInRect:withFont:] in Image Context?
  • Previous by thread: Re: UIKeyboard (without Text filed)
  • Next by thread: Re: [SOLVED] -[drawInRect:withFont:] in Image Context?
  • Index(es):
    • Date
    • Thread