Explicitly disabling UIView animation in iOS4+

前端 未结 5 1024
予麋鹿
予麋鹿 2020-12-31 07:33

I have been reading that Apple recommends to use block-based animations instead of CATransaction

Before, I was using this code to disable animations:



        
5条回答
  •  南方客
    南方客 (楼主)
    2020-12-31 08:30

    // Disable animations
    UIView.setAnimationsEnabled(false)
    
    // ...
    // VIEW CODE YOU DON'T WANT TO ANIMATE HERE
    // ...
    
    // Force view(s) to layout
    yourView(s).layoutIfNeeded()
    
    // Enable animations
    UIView.setAnimationsEnabled(true)
    

提交回复
热议问题