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)
Partial workaround - manually recreate image from CGImage and assign scale factor of 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()
}