Hi, I have the feature to implement in iWatch, where the image has to be rotated in 360 degrees based on the iWatch heading values. The image object "WKInterfaceImage" does not inherit a property called "transform". Shall I get to know how to rotate an image in iWatch or is it even possible to achieve this rotation feature? Thanks in advance for any feedback.
How to rotate image in Apple Watch under swift language
If you rotate 360 you get the image in initial orientation.
Could you show code ?
note also that it is not iWatch, just Watch or better Apple Watch.
Hi, Thank You for reaching out to the query, below is the code in Apple Watch target
The outlet of the image object: -
@IBOutlet weak var headingIcon: WKInterfaceImage!
func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) {
HeadingValue = Double(round(1 * newHeading.trueHeading) / 1).
let newHeadings = Double(newHeading.trueHeading)
// need to place image object here.
// but it is not inheriting the transform property as UIImageView inherits in iOS.
headingIcon.
}
It seems to have to do it by yourself. https://stackoverflow.com/questions/33090032/how-can-i-transform-an-image-for-apple-watch
You could also pass the original image to the Watch class, then transform this image and use setImage.
Actually, I could animate the image into 360 degrees by creating 360 sets of images with respect to 360 angles. but it is actually a good way? In your above answer, do you mean that we cannot rotate a single image in 360 degrees? because the stack overflow answer meant in that way.