【问题标题】:WatchOS5 - what is the "Graphic rectangular" complication image size?WatchOS5 - “图形矩形”复杂图像大小是多少?
【发布时间】:2018-10-13 23:24:46
【问题描述】:

我在看this list of complication images for WatchOS5 by Apple,它提到44mm watch 上的图形矩形复杂度模板为 342px × 108px (171pt × 54pt @2x)

我尝试发送342x108 图像,但它太大 - 似乎默认缩放模式是"center"。我也试过 171x54,它太小而且太模糊 - 我在 Apple Watch 上显示的其他图像更清晰

Graphic Rectangular WatchOS5 复杂功能的正确尺寸/比例是多少?应用或 watchkit/扩展是否可以查询可用于复杂功能的矩形?

    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)

【问题讨论】:

    标签: apple-watch image-scaling apple-watch-complication watchos-5


    【解决方案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()
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多