Как можно совместить анимацию iOS iMessage Extension с анимацией UINavigationController? - PullRequest
0 голосов
/ 06 июля 2019

В iOS iMessage Extension как я могу объединить анимацию из-за изменения стиля презентации MSMessagesAppViewController с push-анимацией UINavigationController?Если попытаться сделать это одновременно, анимация не будет плавной и выглядит не очень хорошо.(Я могу сделать одну анимацию, а затем другую, но это заставляет приложение чувствовать себя очень медленно.)

Вот как это выглядит на обычной скорости и в замедленной съемке.

Fast Slow

/// (Example uses the Xcode iMessage app template)
import Messages
import UIKit

class MessagesViewController: MSMessagesAppViewController {
  var nav: UINavigationController!

  override func viewDidLoad() {
    super.viewDidLoad()
    let parentVC = testViewController(title: "parent", color: .orange)
    nav = UINavigationController(rootViewController: parentVC)
    addChild(nav)
    view.addSubview(nav.view)
    nav.didMove(toParent: self)
  }

  override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    super.touchesBegan(touches, with: event)

    let childVC = testViewController(title: "child", color: .purple)

    // Help! How do I animate both of these at the same time?
    requestPresentationStyle(.expanded)
    nav.pushViewController(childVC, animated: true)
  }

}


func testViewController(title: String, color: UIColor) -> UIViewController {
  let vc = UIViewController()
  vc.view.backgroundColor = color
  vc.title = title
  return vc
}
...