我可以在同一指标上设置当前时间和缓冲区限制

时间:2013-05-07 16:32:15

标签: ios objective-c

我需要在我的AVPlayer实例的同一UIProgressView上显示当前时间(蓝色)和缓冲区限制(灰色)。有可能吗?

1 个答案:

答案 0 :(得分:0)

您需要使用NSAttributedStrings来完成此任务。

Attributed Strings

这是一个例子...... 创建一个包含UILabel和UIProgressView作为子视图的自定义UIView。

NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Hello. That is a test attributed string."];
[str addAttribute:NSBackgroundColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(3,5)];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(10,7)];
[str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:20.0] range:NSMakeRange(20, 10)];
label.attributedText = str;

以下是custom UIProgressView implementation

的示例