在iOS iMessage Extension中,如何将MSMessagesAppViewController
的演示样式更改中的动画与UINavigationController
的推送动画相结合?如果尝试同时进行动画处理,则动画将不流畅且看起来也不是很好。 (我可以先制作一个动画,然后再制作另一个动画,但这会使应用感觉很慢。)
这是正常速度和慢动作的样子。
/// (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
}