rounded settings are ubiquitous in iOS and are easy to develop, but sometimes if a page has a large number of images that need to be rounded, it is easy to create performance problems, Uiimageview ios9.0 before setting the fillet will produce off-screen rendering,after 9.0 will not produce off-screen rendering
So you need to add some changes to the way you want to set round corners on a daily basis:
1. The simplest picture fillet setting:
Self.imageview=[[uiimageview Alloc]initwithframe:cgrectmake (100,200, N.)]; [Self.imageview setimage:[uiimage imagenamed:@ "flyelephant.jpg"]; self.imageview.layer.cornerradius=50; Self.imageview.layer.maskstobounds=yes; [Self.view AddSubview:self.imageView];
2. Set rasterize raster processing, will put the picture in the buffer, do not continue to do picture rendering:
Self.imageview=[[uiimageview Alloc]initwithframe:cgrectmake (100,200, N.)]; [Self.imageview setimage:[uiimage imagenamed:@ "dress3.jpg"]; self.imageview.layer.cornerradius=50; Self.imageView.layer.shouldRasterize = YES; Self.imageview.clipstobounds=yes; Self.imageview.layer.rasterizationscale=[uiscreen Mainscreen].scale; Do not set will blur, do not believe you can try [Self.view AddSubview:self.imageView];
3.UIBezierPath Bézier curve drawing (recommended)
Self.imageview=[[uiimageview Alloc]initwithframe:cgrectmake (100,200, N.)]; UIImage *anotherimage = [UIImage imagenamed:@ "flyelephant.jpg"]; Note The third option is set uigraphicsbeginimagecontextwithoptions (Self.imageView.bounds.size, NO, [UIScreen mainscreen]. scale); Crop a circle before drawing [[Uibezierpath bezierPathWithRoundedRect:self.imageView.bounds cornerradius:50] Addclip] ; The picture is drawn inside the set circle [Anotherimage drawInRect:self.imageView.bounds]; Get picture self.imageView.image = Uigraphicsgetimagefromcurrentimagecontext (); Finish Drawing uigraphicsendimagecontext (); [Self.view AddSubview:self.imageView];
Reference: Http://stackoverflow.com/questions/11049016/cliptobounds-and-maskstobounds-performance-issue
Http://stackoverflow.com/questions/17593524/using-cornerradius-on-a-uiimageview-in-a-uitableviewcell
iOS development-uiimageview efficiently set up radius