Update CALayer sublayers immediately

前端 未结 1 912
[愿得一人]
[愿得一人] 2021-01-07 00:03

I have UIView which has the following structure:

UIView
  |- layer (CALayer)
    |- depthLayer (CALayer)
    |- bodyLayer (CALayer)

For

相关标签:
1条回答
  • 2021-01-07 00:19

    The delays you see in your CALayer's frames are cause because the Animations -> when you making a change to the CALayer's appearance It tries to animate it (and it often successes -> well this is why they called animations layers).

    To disable this behavior (animations) you should call the disable transactions like this:

    CATransaction.setValue(kCFBooleanTrue, forKey:kCATransactionDisableActions) //..Make Change to the frames here CATransaction.commit()

    Also I don't know wether you have a real need to override the drawRect for this matter -> if you set the UIView's Frame via setFrame: method, it is better to override the setFrame: method itself and adjust the Frames of subLayers there.

    Lot of Luck!

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