mirror of
https://github.com/material-components/material-components-ios.git
synced 2026-02-15 15:59:31 +08:00
This simplifies the layers between the app developer and the transition implementation while also allowing us to reduce the complexity of the MotionTransitioning APIs. In the near future we will remove nearly all of the MotionTransitioning abstractions in favor of providing a small set of tools and APIs for building plain UIKit transitions.
Notably:
- MaskedTransition is now a private API.
- There is a new MaskedTransitionController type that must be instantiated and stored for the lifetime of the presented view controller.
- MaskedTransition is no longer a Transition type.
- MaskedTransition now simply implements the animated view controller transitioning APIs.
- MaskedTransitionController vends MaskedTransition instances as required.
Example usage:
```swift
let transitionController = MDCMaskedTransitionController()
func didTapFab(fab: UIView) {
let vc = SomeViewController()
vc.view.autoresizingMask = [.flexibleLeftMargin, .flexibleTopMargin,
.flexibleRightMargin, .flexibleBottomMargin]
// Customize the transition
transitionController.sourceView = fab
transitionController.calculateFrameOfPresentedView = { info in
let size = CGSize(width: 200, height: 200)
return CGRect(x: (info.containerView!.bounds.width - size.width) / 2,
y: (info.containerView!.bounds.height - size.height) / 2,
width: size.width,
height: size.height)
}
vc.modalPresentationStyle = .custom
vc.transitioningDelegate = transitionController
showDetailViewController(vc, sender: self)
}
```