大佬教程收集整理的这篇文章主要介绍了在iOS中渲染圈子的最佳技巧是什么?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
使用像circle-icon.png和circle-icon@2px.png这样的图像.然后,可以实现以下代码以使iOS自动呈现适当的大小:
UIImage *image = [UIImage imagenamed:@"circle-icon"]; self.closeIcon = [[UIImageView alloc] initWithImage:image]; self.closeIcon.frame = CGRectMake(300,16,image.size.width,image.size.height);
渲染圆角和使用图层,如下所示:
self.circleView = [[UIView alloc] initWithFrame:CGRectMake(10,20,100,100)]; circleView.alpha = 0.5; self.circleView.layer.cornerRadius = 50; self.circleView.BACkgroundColor = [UIColor blueColor];
使用原生绘图库,使用CGContextFillEllipseInRect之类的东西
UIBezierPath
和
CAShapeLayer
.创建一个圆形的UIBezierPath,创建一个使用该UIBezierPath的CAShapeLayer,然后将该层添加到视图/图层层次结构中.
> Add the QuartzCore framework to your project.
>其次,导入适当的标题:
#import <QuartzCore/QuartzCore.h>
UIBezierPath *path = [UIBezierPath bezierPath]; [path addArcWithCenter:CGPointMake(self.view.bounds.size.width / 2.0,self.view.bounds.size.height / 2.0) radius:self.view.bounds.size.width * 0.40 startAngle:0 endAngle:M_PI * 2.0 clockwise:YES]; CAShapeLayer *layer = [[CAShapeLayer alloc] init]; layer.path = [path CGPath]; layer.fillColor = [[UIColor blueColor] CGColor]; [self.view.layer addSublayer:layer];
我认为CoreGraphics实现或者这个CAShapeLayer实现比PNG文件或带圆角的UIView对象更有意义.
以上是大佬教程为你收集整理的在iOS中渲染圈子的最佳技巧是什么?全部内容,希望文章能够帮你解决在iOS中渲染圈子的最佳技巧是什么?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。