CAShapeLayer
来源:互联网 发布:炮姐脸型数据 编辑:程序博客网 时间:2024/05/21 08:41
CAShapeLayer is a CALayer subclass that let you draw various shapes on screen, from the very simple to the most complex.
First at all,
let photoLayer = CALayer()let circleLayer = CAShapeLayer()let maskLayer = CAShapeLayer()
the code above creates three layers,one CALayer,two CAShapeLayers
photoLayer.contents = image.CGImage
assign an image to photoLayer.contents , the image will fill into photoLayer.
photoLayer.frame = CGRect( x: (bounds.size.width - image.size.width + lineWidth)/2, y: (bounds.size.height - image.size.height - lineWidth)/2, width: image.size.width, height: image.size.height) //Draw the circle circleLayer.path = UIBezierPath(ovalInRect: bounds).CGPath circleLayer.strokeColor = UIColor.whiteColor().CGColor circleLayer.lineWidth = lineWidth circleLayer.fillColor = UIColor.clearColor().CGColor //Size the layer maskLayer.path = circleLayer.path maskLayer.position = CGPoint(x: 0.0, y: 10.0) layer.addSublayer(photoLayer); photoLayer.mask = maskLayer; layer.addSublayer(circleLayer);
We should set a CALayer’s frame, and set a CAShapeLayer’s path instead .
0 0
- CAShapeLayer
- CAShapeLayer
- CAShapeLayer
- CAShapeLayer
- CAShapeLayer
- CAShapeLayer
- CAShapeLayer
- CAShapeLayer
- CAShapeLayer
- CAShapeLayer
- CAShapeLayer使用
- CAShapeLayer FontAwesome
- CAShapeLayer UIBezierPath
- CAShapeLayer简介
- CAShapeLayer相关内容
- IOS - CAShapeLayer
- iOS CAShapeLayer
- CAShapeLayer学习
- TCP的三次握手,四次挥手
- Eclipse注释模板设置详解
- Oracle的备份方式
- Java环境变量设置
- 虚拟机的三种网络模式
- CAShapeLayer
- play的模板语法
- 一个完整的Servlet需要哪些。
- TabLayout禁止选择
- OpenGL ES 纹理设置
- HTML5 表单元素在 Android 下被软键盘遮挡
- 198.Permutation Index II-排列序号II(中等题)
- 225. Implement Stack using Queues
- iOS 开发中你是否遇到这些经验问题