MKAnnotationView setImage () on iOS 11 has animation

Since iOS 11, when I use setImagein my custom MKAnnotationView, the image is displayed with animation.

The problem is that I select and deselect MKAnnotationView, and the image has a different size. This leads to a weird animation.

No problem before iOS 11, can this behavior be stopped?

+4
source share
1 answer

Seeing that this is the only mention of this problem (function?) That I discovered somewhere in the past year and a half, let me first thank you for being my only source of sanity. With this, I was finally able to go back and demystify it ... sort of. I have yet to radar just because it is unclear whether this behavior is intended. Whatever the correct behavior, the animation has some weird side effects, which led me to a separate issue .

This problem

, image , . , UIKit . , :

CATransaction.begin()
CATransaction.setDisableActions(true)
annotationView.image = newImage
CATransaction.commit()

, , , . , , , (, centerOffset centerOffset), centerOffset, not , , UIKit- . , UIKit CoreAnimation:

CATransaction.begin()
CATransaction.setAnimationDuration(animationDuration)
CATransaction.setAnimationTimingFunction(CAMediaTimingFunction(name: .easeIn))

UIView.animate(withDuration: animationDuration, delay: 0, options: .curveEaseIn, animations: {
    self.image = newImage
    self.centerOffset = newCenterOffset
}, completion: nil)

CATransaction.commit()

UIKit, CoreAnimation.

0

Source: https://habr.com/ru/post/1687997/


All Articles