iPhone: How can I rotate UIImageView without blockiness?
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