Skip to content

UIProgressView:progressImage 属性 ​

progressImage 属性是进度条填满的那一段用的图片。

值 ​

UIImage,或者 null。

  • 可读,可写。
  • 默认值是 null。
  • 读回来是写进去的同一个对象。
  • 写 null 去掉图片。
  • 和 progressTintColor 二选一:写入一张图片时,progressTintColor 变成 null;之后再写颜色,图片变成 null。见颜色和图片二选一。
  • 图片怎么拉伸和裁剪未在模拟器验证。
  • 没有变化事件。只有 App 自己的代码会改它。

写错时 ​

写入 UIImage 和 null 以外的值抛 TypeError,原值不变:

  • 写别的原生对象(比如 UIColor):progressImage needs a UIImage or null。
  • 写字符串等普通值:progressImage needs a native object or null, got "star.fill"。

示例 ​

js
const bar = new UIProgressView();
bar.progressTintColor = 'systemRed';
const star = UIImage.systemImageNamed('star.fill');
if (star) bar.progressImage = star;
console.log(bar.progressTintColor);

结果:输出 null。写图片时系统清掉了刚才写的颜色,填满的那一段改用这张图。

对应的 iOS API ​

UIProgressView.progressImage。

参见 ​