国产探花免费观看_亚洲丰满少妇自慰呻吟_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"];}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 东丽区| 西昌市| 金寨县| 杂多县| 五指山市| 平顶山市| 大城县| 高唐县| 望江县| 五家渠市| 阆中市| 三都| 郁南县| 潜山县| 博罗县| 上蔡县| 乌拉特后旗| 唐河县| 大悟县| 河池市| 景德镇市| 民权县| 台东县| 桂平市| 达孜县| 新昌县| 炉霍县| 舟山市| 武义县| 南靖县| 胶州市| 文昌市| 正宁县| 商水县| 建瓯市| 凤庆县| 阆中市| 呼玛县| 新和县| 沈丘县| 乐清市|