2

所以我试图让我的 watchOS 2 复杂功能显示图像。研究让我找到了这些链接:

https://www.bignerdranch.com/blog/watchkit-2-complications/ http://techotopia.com/index.php/A_watchOS_2_Complication_Tutorial https://developer.apple.com/library/prerelease/watchos/documentation/ClockKit /Reference/CLKImageProvider_class/index.html#//apple_ref/occ/cl/CLKImageProvider https://forums.developer.apple.com/thread/7426

我已经尝试使用图像资产来解决复杂问题,以及仅将单个图像导入项目中。我加载图像的代码如下:

lazy var utilitarianImageProvider: CLKImageProvider? = {
    if let image = UIImage(named: "Complication/Utilitarian") {
        return CLKImageProvider(onePieceImage: image)
    }
    else {
        print("Cannot find image named 'Complication/Utilitarian'")
    }
    return nil
}()

但这只会导致这个图像:

watchOS 2 并发症

我要加载的图像是:

标识

我尝试了彩色图像和单色图像,但总是得到相同的结果。

4

1 回答 1

3

尝试将黑色背景设置为透明。图像被视为仅 alpha,这意味着图像文件中的所有颜色都将被丢弃,手表将相应地对其进行着色。

于 2015-11-26T07:18:48.007 回答