首页 > 解决方案 > 为 WKInterfaceImage 着色?

问题描述

我正在使用在 iPhone 上运行良好的代码,但我需要在 WatchKit 中为 WKImage 着色,我该怎么做?我尝试对 WKInterfaceImage 上的扩展使用相同的代码,但该image属性仅获取。

extension UIImageView {
    func setImageColor(color: UIColor) {
        let templateImage = self.image?.withRenderingMode(UIImage.RenderingMode.alwaysTemplate)
        self.image = templateImage
        self.tintColor = color
    }
}

如何在 Swift 中为 UIImage 着色?

标签: iosswiftwatchkitapple-watch

解决方案


推荐阅读