I can at least show you a shortcut for drawing circles of any size. No OpenGL, no graphic drawing of Core required.
Import the QuartzCore environment to access the .cornerRadius property of your UIView or UIImageView.
#import <QuartzCore/QuartzCore.h>
Also manually add it to your project file folder.
Add this method to your view controller or where you need it:
-(void)setRoundedView:(UIImageView *)roundedView toDiameter:(float)newSize; { CGPoint saveCenter = roundedView.center; CGRect newFrame = CGRectMake(roundedView.frame.origin.x, roundedView.frame.origin.y, newSize, newSize); roundedView.frame = newFrame; roundedView.layer.cornerRadius = newSize / 2.0; roundedView.center = saveCenter; }
To use it, just pass it a UIImageView and diameter. This example assumes that a UIImageView named "circ" is added as a subview to your view. It must have a backgroundColor set so you can see it.
circ.clipsToBounds = YES; [self setRoundedView:circ toDiameter:100.0];
This just handles UIImageViews, but you can generalize it to any UIView.
NOTE. . Since iOS 7, clipToBounds need YES.
willc2 Dec 13 '09 at 13:45 2009-12-13 13:45
source share