How reliable is KVO with UIKit

后端 未结 1 1983
孤城傲影
孤城傲影 2020-12-06 05:31

Important: Not all classes are KVO-compliant for all properties. You can ensure your own classes are KVO-compliant by following the steps described in

相关标签:
1条回答
  • 2020-12-06 05:58

    UIKit is mostly NOT KVO compliant. This is mostly because UIView acts as high-level wrapper for CALayer, so when you eg. change the frame property of an UIView, it will change the layers frame but leave eg. the bounds property of the UIView untouched, so no observer will be triggered for the view.bounds path, because it never really changes. And this leads to non KVO compliance.

    Only if the property is marked as KVO compliant can you rely on this, otherwise it will not work or break in some weird cases.

    0 讨论(0)
提交回复
热议问题