WatchOS5 - "Graphic rectangular" 并发症图像大小是多少?
WatchOS5 - what is the "Graphic rectangular" complication image size?
我正在查看 this list of complication images for WatchOS5 by Apple,其中提到 44mm watch
上的图形矩形复杂功能模板为 342px × 108px (171pt × 54pt @2x)
我尝试发送 342x108
图片,但它太大了 - 默认缩放模式似乎是 "center"
。我也试过 171x54,但它太小而且模糊 - 我在 Apple Watch 上显示的其他图像更清晰
图形矩形 WatchOS5 复杂功能的正确尺寸/比例是多少?应用程序或 watchkit/exstension 是否可以查询可用于复杂功能的矩形?
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)
部分解决方法 - 从 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()
}
我正在查看 this list of complication images for WatchOS5 by Apple,其中提到 44mm watch
上的图形矩形复杂功能模板为 342px × 108px (171pt × 54pt @2x)
我尝试发送 342x108
图片,但它太大了 - 默认缩放模式似乎是 "center"
。我也试过 171x54,但它太小而且模糊 - 我在 Apple Watch 上显示的其他图像更清晰
图形矩形 WatchOS5 复杂功能的正确尺寸/比例是多少?应用程序或 watchkit/exstension 是否可以查询可用于复杂功能的矩形?
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)
部分解决方法 - 从 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()
}