国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

橢圓線條繪制動畫

2019-11-09 16:53:47
字體:
來源:轉載
供稿:網友

github:https://github.com/potato512/SYAnimation

使用貝賽爾曲線UIBezierPath、陰影對象CAShapeLayer、基礎類動畫CABasicAnimation實現。

效果圖如下:

示例代碼:

- (void)lineAnimation{    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(10.0, 340.0, (self.view.frame.size.width - 10.0 * 2), 100.0)];    [self.view addSubview:view];    view.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.2];    UIBezierPath *bezierPath = [UIBezierPath bezierPathWithOvalInRect:view.bounds];     CAShapeLayer *shapeLayer = [[CAShapeLayer alloc] init];    shapeLayer.strokeColor = [UIColor purpleColor].CGColor;    shapeLayer.fillColor = [UIColor clearColor].CGColor;    shapeLayer.lineWidth = 2;    shapeLayer.lineJoin = kCALineJoinRound;    shapeLayer.lineCap = kCALineCaPRound;    shapeLayer.path = bezierPath.CGPath;    [view.layer addSublayer:shapeLayer];        CABasicAnimation *pathAnim = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];    pathAnim.duration = 5.0;    pathAnim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaSEOut];    pathAnim.fromValue = @(0);    pathAnim.toValue = @(1);    pathAnim.autoreverses = true;    pathAnim.fillMode = kCAFillModeForwards;    pathAnim.removedOnCompletion = NO;    pathAnim.repeatCount = MAXFLOAT;    [shapeLayer addAnimation:pathAnim forKey:@"strokeEndAnim"];}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 襄樊市| 兰坪| 通州区| 龙陵县| 永年县| 雷波县| 景宁| 泰安市| 郯城县| 文山县| 天全县| 阜平县| 玛沁县| 丰原市| 阳江市| 清流县| 兴城市| 通江县| 延长县| 安溪县| 廉江市| 双城市| 威信县| 密云县| 江川县| 光山县| 巴林左旗| 乌拉特中旗| 瓦房店市| 新昌县| 新建县| 兰西县| 肥东县| 苏尼特右旗| 益阳市| 康平县| 邹平县| 濮阳县| 堆龙德庆县| 十堰市| 封丘县|