3

I'm looking at this list of complication images for WatchOS5 by Apple, it mentions template for the graphic rectangular complication on 44mm watch being 342px × 108px (171pt × 54pt @2x)

I tried sending 342x108 image, and it is too large - it appears the default scaling mode is "center". I also tried 171x54 and it is too small and blurry - other images I display on apple watch are much more crisp

What is the correct size /scale for the Graphic Rectangular WatchOS5 complication ? Is it possible for the app or watchkit/exstension to query the rectangle available for complication?

    var image: UIImage = UIImage()

    let fileManager = FileManager.default
    do {
        let fileURL = try //...URL of complication file

        let data = try Data(contentsOf: fileURL)
        image = UIImage(data: data)

    } catch {
        image =  UIImage(named: "placeholder") ?? UIImage()
    }

    let textProvider = CLKSimpleTextProvider(text: SessionDelegater.title)
    template.textProvider = textProvider
    template.imageProvider = CLKFullColorImageProvider(fullColorImage: image)
4

1 回答 1

1

部分解决方法 - 从 CGImage 手动重新创建图像并将比例因子分配为 2:

        var image: UIImage = UIImage()
        do {
            let fileURL = try FileManager.fileURL("complication")

            let data = try Data(contentsOf: fileURL)
            image = UIImage(data: data) ?? UIImage()
            if let cgImage = image.cgImage {
                  image =  UIImage(cgImage: cgImage, scale: 2, orientation: image.imageOrientation)
            }

        } catch {
            print(error)

            image =  UIImage(named: "image1") ?? UIImage()
        }
于 2018-10-14T10:26:38.520 回答