• 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
iPhone: How can I rotate UIImageView without blockiness?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

iPhone: How can I rotate UIImageView without blockiness?


  • Subject: iPhone: How can I rotate UIImageView without blockiness?
  • From: "Eric E. Dolecki" <email@hidden>
  • Date: Wed, 5 Aug 2009 14:34:52 -0400

I am making an analog clock, and I have 3 PNGs for the arms. I am rotating
these, but they look awful with blocky edges. The second hand is a pixel
wide for instance. Is there a trick to use smoothing (aliasing) or
something?



Here is the method I call via NSTimer every second. Is there a better way to
this (I don't know OpenGL or anything like that at the moment)? CALayer?


- (void) showActivity {
NSCalendar *gregorian = [[NSCalendar alloc]
initWithCalendarIdentifier:NSGregorianCalendar];
unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit |
NSDayCalendarUnit | NSHourCalendarUnit| NSMinuteCalendarUnit
|NSSecondCalendarUnit;
NSDate *date = [NSDate date];
     NSDateComponents *comps = [gregorian components:unitFlags fromDate:date];
     int h = [comps hour];
     int m = [comps minute];
     int s = [comps second];

CGAffineTransform cgaRotateHr  =
CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(h * 30));
CGAffineTransform cgaRotateMin =
CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(m * 6));
CGAffineTransform cgaRotateSec =
CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(s * 6));

        //Looks awful but it works (PNGs with transparency have blocked edges)
     [hrHand setTransform:cgaRotateHr];
     [minHand setTransform:cgaRotateMin];
     [secondHand setTransform:cgaRotateSec];

NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
     [formatter setTimeStyle:NSDateFormatterMediumStyle];
     [clockLabel setText:[formatter stringFromDate:date]];
}
_______________________________________________

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

  • Prev by Date: Re: Generating random numbers
  • Next by Date: Re: How can we distinguish which alert we are talking about?
  • Previous by thread: Re: How can we distinguish which alert we are talking about?
  • Next by thread: [iPhone] Webview stringByEvaluatingJavaScriptFromString
  • Index(es):
    • Date
    • Thread