iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
IsaacYoung
V2EX  ›  iDev

新手请教如何处理动画过程中旋转屏幕

  •  
  •   IsaacYoung · Jun 26, 2020 · 2947 views
    This topic created in 2149 days ago, the information mentioned may be changed or developed.
    最近学习 iOS 开发做一个 demo App,效果是类似发牌的动画,卡牌堆在左下角,点击发牌,会从卡牌堆取三张卡片,通过 UIViewPropertyAnimator 移动到指定位置,如果动画执行过程中旋转屏幕,卡牌的宽高和要移动到目标位置可能会发生改变,怎么处理这种场景呢
    1 replies    2020-07-01 16:02:01 +08:00
    chipmuck
        1
    chipmuck  
       Jul 1, 2020
    可以重写 viewWillTransition(to:with:) 这个方法:

    1. size 参数表示旋转后的 CGSize 值;
    2. coordinator 可以调用 animate(alongsideTransition:completion:) 来调整旋转时和旋转后你所想要更新的 UI 布局。

    具体的文档地址参考:

    https://developer.apple.com/documentation/uikit/uicontentcontainer/1621466-viewwilltransition
    https://developer.apple.com/documentation/uikit/uiviewcontrollertransitioncoordinator/1619300-animate
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2979 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 04:56 · PVG 12:56 · LAX 21:56 · JFK 00:56
    ♥ Do have faith in what you're doing.