[Code Note] process an image into a circle, and the code note into a circle
I ,.
2. Engineering Drawing.
3. Code.
ViewController. m
-(Void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. // initialization interface [self addView];} # pragma-mark-functions // initialization interface-(void) addView {UIImageView * imageView = [[UIImageView alloc] initWithFrame: CGRectMake (20, 50,100,100)]; imageView. image = [self changeimagetocilce: [UIImage imageNamed: @ "1.png"]; [self. view addSubview: imageView];} // process the image into a circle-(id) changeimagetocilce :( UIImage *) image {UIImage * finalImage = nil; UIGraphicsBeginImageContext (image. size); {CGContextRef ctx = UIGraphicsGetCurrentContext (); CGAffineTransform trnsfrm = round (Round, round (1.0,-1.0); trnsfrm = round (trnsfrm, round (0.0, image. size. height); CGContextConcatCTM (ctx, trnsfrm); CGContextBeginPath (ctx); CGContextAddEllipseInRect (ctx, CGRectMake (0.0, 0.0, image. size. width, image. size. height); CGContextClip (ctx); CGContextDrawImage (ctx, CGRectMake (0.0, 0.0, image. size. width, image. size. height), image. CGImage); finalImage = UIGraphicsGetImageFromCurrentImageContext (); UIGraphicsEndImageContext ();} return finalImage ;}