toa*_*ndk 0 objective-c uiprogressview uiprogressbar ios progress-bar
我想用UIKIT定制一个矩形进度条,就像吸引的图像一样.有没有任何源代码?Cocos2d与CCProgressTimer具有相同的功能,但我找不到任何UIKIT源代码.

创建一个ShapedLayer
CAShapeLayer *layer = [CAShapeLayer layer];
[layer setStrokeColor:[UIColor greenColor].CGColor];
[layer setLineWidth:10.0f];
[layer setFillColor:[UIColor clearColor].CGColor];
Run Code Online (Sandbox Code Playgroud)
在你想要动画的地方创建一个带有radious的rect
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(10, 10, 300, 200) cornerRadius:10.0f];
layer.path = path.CGPath;
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
animation.fromValue = [NSNumber numberWithFloat:0.0f];
animation.toValue = [NSNumber numberWithFloat:1.0f];
Run Code Online (Sandbox Code Playgroud)
定义动画持续时间
animation.duration = 4.0f;
[layer addAnimation:animation forKey:@"myStroke"];
Run Code Online (Sandbox Code Playgroud)
将动画添加到要显示的图层
[self.view.layer addSublayer:layer];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2303 次 |
| 最近记录: |