五角大楼画一个小圆圈戴:

- (void)drawPentagon{

//(1)UIBezierPath对象

UIBezierPath *aPath = [UIBezierPath
bezierPath];

//開始点

[aPath moveToPoint:CGPointMake(100.0,
1.0)];

//划线点

[aPath addLineToPoint:CGPointMake(200.0,
40.0)];

[aPath addLineToPoint:CGPointMake(160,
140)];

[aPath addLineToPoint:CGPointMake(40.0,
140)];

[aPath addLineToPoint:CGPointMake(0.0,
40.0)];

[aPath closePath];

//设置定点是个5*5的小圆形(自己加的)

UIBezierPath *path = [UIBezierPath
bezierPathWithOvalInRect:CGRectMake(100-5/2.0,
0, 5,
5)];

[aPath appendPath:path];

//(2)加到CAShapeLayer,效果出来了

CAShapeLayer *shapelayer = [CAShapeLayer
layer];

//设置边框颜色

shapelayer.strokeColor = [[UIColor
redColor]CGColor];

//设置填充颜色

shapelayer.fillColor = [[UIColor
whiteColor]CGColor];

//就是这句话在关联彼此(UIBezierPath和CAShapeLayer):

shapelayer.path = aPath.CGPath;

[self.view.layer
addSublayer:shapelayer];

}

版权声明:本文博客原创文章。博客,未经同意,不得转载。

UIBezierPath 和 CAShapeLayer 绘画图纸的更多相关文章

  1. 放肆的使用UIBezierPath和CAShapeLayer画各种图形

    CAShapeLayer 是 CALayer 的子类,但是比 CALayer 更灵活,可以画出各种图形,当然,你也可以使用其他方式来画,随你. 杂谈 在 CAShapeLayer 中,也可以像 CAL ...

  2. 使用UIBezierPath和CAShapeLayer画各种图形

    转载自:http://www.cocoachina.com/ios/20160214/15251.html CAShapeLayer 是 CALayer 的子类,但是比 CALayer 更灵活,可以画 ...

  3. iOS 使用UIBezierPath和CAShapeLayer画各种图形

    CAShapeLayer 是 CALayer 的子类,但是比 CALayer 更灵活,可以画出各种图形,当然,你也可以使用其他方式来画,随你. 杂谈 在 CAShapeLayer 中,也可以像 CAL ...

  4. UIBezierPath和CAShapeLayer的关系

    CAShapeLayer是基于贝塞尔曲线而存在的, 如果没有贝塞尔曲线提供路径来画出图形, CAShapeLayer就没有存在的意义, CAShapeLayer可以使得不用在drawRect:方法中实 ...

  5. UIBezierPath与CAShapeLayer结合画扇形

    /*让半径等于期望半径的一半 lineWidth等于期望半径 就可以画圆*/ 可以看出layer的走势是从圆边的中间一半在圆外 一半在圆内 因此让半径等于期望半径的一半 lineWidth等于期望半径 ...

  6. UIBezierPath和CAShapeLayer配合肆意画图

    一.CAShapeLayer CAShapeLayer 是 CALayer 的子类,但是比 CALayer 更灵活,可以画出各种图形   使用CAShapeLayer 绘制一个矩形 let layer ...

  7. iOS关于CAShapeLayer与UIBezierPath的知识内容

    使用CAShapeLayer与UIBezierPath可以实现不在view的drawRect方法中就画出一些想要的图形 . 1:UIBezierPath: UIBezierPath是在 UIKit 中 ...

  8. 使用CAShapeLayer与UIBezierPath画出想要的图形

    使用CAShapeLayer与UIBezierPath可以实现不在view的drawRect方法中就画出一些想要的图形 步骤: 1.新建UIBezierPath对象bezierPath 2.新建CAS ...

  9. 贝赛尔曲线UIBezierPath(后续)

    使用CAShapeLayer与UIBezierPath可以实现不在view的drawRect方法中就画出一些想要的图形 . 1:UIBezierPath: UIBezierPath是在 UIKit 中 ...

随机推荐

  1. uva10791 uva10780(分解质因数)

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  2. 采用PopupWin控制消息推送功能

    最近的项目需要,急需实现消息推送功能.接连试了很多办法,让我们用JavaScript为了实现啊,其效果是不咋好,最后,我发现了一个PopupWin这个,看着眼前的成绩不错,开始使用. 1.准备工作.先 ...

  3. singleton pattern

    1 normal mode class Singleton { private Singleton(){}; Singleton singleton; static Singleton getInst ...

  4. UIScrollViewA都PI得知。

    //1.设定滚定条的样式 typedef NS_ENUM(NSInteger, UIScrollViewIndicatorStyle) { UIScrollViewIndicatorStyleDefa ...

  5. 利用HttpOnly来防御xss攻击

    xss的概念就不用多说了,它的危害是极大的,这就意味着一旦你的站点出现xss漏洞,就能够运行随意的js代码,最可怕的是攻击者利用js获取cookie或者session劫持,假设这里面包括了大量敏感信息 ...

  6. partial 的好处

    1.可以将一个类中的属 性, 方法分类来写 2.方法了可以写在多个类中, 这样可以对方法进行分类   由于项目上使用了代码生成工具, 自定义的一些按钮事件默认是不生成的,得自己定义,如果把定义的代码写 ...

  7. [ACM] poj 3468 A Simple Problem with Integers(段树,为段更新,懒惰的标志)

    A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K Total Submissions: 55273   ...

  8. Directx11学习笔记【三】 第一个D3D11程序

    在先前的解决方案中新建一个新的Win32项目FirstD3D11Demo.在写代码之前,我们必须先添加dx11所需要的库.为了链接dx库,右键项目选择属性->vc++目录,在包含目录中添加你所安 ...

  9. 【Android进阶】android:configChanges属性总结

    android中的组件Activity在manifest.xml文件中可以指定参数android:ConfigChanges,用于捕获手机状态的改变. 在Activity中添加了android:con ...

  10. Java 解析 lnk 快捷方式文件的方法(转)

    package file.extendsion; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.F ...