已添加一些附加属性以绘制类似这样的东西
https://www.dropbox.com/s/dmyebdgkx8zb1j9/Screenshot%202014-06-13%2012.21.35.png
从 1.3.2 版开始增加了更多外观
// appearance
[[LFProgressView appearance] setFlat:@YES];
[[LFProgressView appearance] setShowStroke:@NO];
[[LFProgressView appearance] setShowBackground:@YES];
[[LFProgressView appearance] setShowBackgroundInnerShadow:@NO];
[[LFProgressView appearance] setOuterStrokeWidth:@0];
[[LFProgressView appearance] setProgressInset:@-1];
[[LFProgressView appearance] setBorderRadius:@0];
// LFProgressView 1.3.2
[[LFProgressView appearance] setTextColor:[UIColor whiteColor]];
[[LFProgressView appearance] setTextAlignment:@(NSTextAlignmentLeft)];
[[LFProgressView appearance] setShowTextShadow:@(YES)];
[[LFProgressView appearance] setShowTextAlways:@(YES)];
[[LFProgressView appearance] setFont:[UIFont fontWithName:@"Ubuntu-Bold" size:11]];
[[LFProgressView appearance] setBackground:[UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:0.50f]];
[[LFProgressView appearance] setStripeWidth:@(10)];
[[LFProgressView appearance] setStripeSlope:@(2)];
1.3.1 版以下
包含以下附加代码
progress1.textAlignment = NSTextAlignmentLeft;
progress1.textColor = [UIColor whiteColor];
progress1.showTextShadow = YES;
progress1.font = [UIFont fontWithName:@"Ubuntu-Bold" size:11.5];
progress1.background = [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:0.50f];
progress1.stripeWidth = 10;
progress1.stripeSlope = 2;
其他代码适用于原始 LDProgressView
LDProgressView* progress1 = [[LDProgressView alloc] initWithFrame:CGRectMake(20, 41, self.view.frame.size.width-40, 20)];
progress1.flat = @YES;
progress1.showStroke = @NO;
progress1.showBackground = @YES;
progress1.showBackgroundInnerShadow = @NO;
progress1.outerStrokeWidth = @0;
progress1.progressInset = @-1;
progress1.progress = 0.40;
progress1.labelProgress = 0.0;
progress1.borderRadius = @0;
progress1.type = LDProgressStripes;
progress1.color = [UIColor orangeColor];
[progress1 overrideProgressText:@"test1"];
[subview addSubview:progress1];
请查看以下关于 LDProgressView 的消息。
一个平面或渐变进度视图,具有简单的颜色设置器和可定制的选项,完全使用 Core Graphics 编写。
showBackgroundInnerShadow
属性showBackground
progressInset
outerStrokeWidth
showStroke
borderRadius
LDProgressStripes
& LDProgressGradient
下载项目的 zip 文件,并将类 LDProgressView
和 UIColor+RGBValues
放入您的项目中。然后在您希望使用它的文件中简单地导入 "LDProgressView.h"。
以下是上面的截图中所看到的示例
// default color, animated
LDProgressView *progressView = [[LDProgressView alloc] initWithFrame:CGRectMake(20, 130, self.view.frame.size.width-40, 22)];
progressView.progress = 0.40;
[self.progressViews addObject:progressView];
[self.view addSubview:progressView];
// flat, green, animated
progressView = [[LDProgressView alloc] initWithFrame:CGRectMake(20, 160, self.view.frame.size.width-40, 22)];
progressView.color = [UIColor colorWithRed:0.00f green:0.64f blue:0.00f alpha:1.00f];
progressView.flat = @YES;
progressView.progress = 0.40;
progressView.animate = @YES;
[self.progressViews addObject:progressView];
[self.view addSubview:progressView];
// progress gradient, red, animated
progressView = [[LDProgressView alloc] initWithFrame:CGRectMake(20, 190, self.view.frame.size.width-40, 22)];
progressView.color = [UIColor colorWithRed:0.73f green:0.10f blue:0.00f alpha:1.00f];
progressView.progress = 0.40;
progressView.animate = @YES;
progressView.type = LDProgressGradient;
progressView.background = [progressView.color colorWithAlphaComponent:0.8];
[self.progressViews addObject:progressView];
[self.view addSubview:progressView];
// solid style, default color, not animated, no text, less border radius
progressView = [[LDProgressView alloc] initWithFrame:CGRectMake(20, 220, self.view.frame.size.width-40, 22)];
progressView.showText = @NO;
progressView.progress = 0.40;
progressView.borderRadius = @5;
progressView.type = LDProgressSolid;
[self.progressViews addObject:progressView];
[self.view addSubview:progressView];
// stripe style, no border radius, default color, not animated
progressView = [[LDProgressView alloc] initWithFrame:CGRectMake(20, 250, self.view.frame.size.width-40, 22)];
progressView.progress = 0.40;
progressView.borderRadius = @0;
progressView.type = LDProgressStripes;
progressView.color = [UIColor orangeColor];
[self.progressViews addObject:progressView];
[self.view addSubview:progressView];
您也可以使用 UIAppearance 协议配置每个 LDProgressView,这可以在您的应用程序代理中完成。以下是一个此类配置的示例
[[LDProgressView appearance] setColor:[UIColor purpleColor]];
[[LDProgressView appearance] setBackground:[UIColor redColor]];
[[LDProgressView appearance] setFlat:@YES];
[[LDProgressView appearance] setAnimate:@YES];
[[LDProgressView appearance] setShowStroke:@YES];
[[LDProgressView appearance] setBorderRadius:@5];
[[LDProgressView appearance] setOuterStrokeWidth:@3];
[[LDProgressView appearance] setShowBackground:@NO];
[[LDProgressView appearance] setProgressInset:@5];
版权所有 (C) 2013 Light Design [email protected]
本协议授予任何获取本软件及其相关文档文件(以下简称“软件”)副本的个人免费权利,无限制地处理软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或出售软件副本的权利,并允许将软件提供给他人进行上述操作,前提是遵守以下条件。
以上版权声明和本许可声明应包含在软件的任何副本或主要部分中。
软件按“现有状态”提供,不提供任何形式的明示或暗示担保,包括但不限于适销性、适用于特定目的和不受侵犯的担保。在任何情况下,作者或版权持有人不应对任何索赔、损害或任何其他责任承担义务,无论这些责任是基于合同、侵权或其他原因,无论这些责任是由于使用软件、使用或软件的其他方式产生的。