iOS基于UIPresentationController的封装

效果图

简单介绍

基于UIPresentationController的封装,支持多种转场效果,还可轻松自定义转场动画。

使用方法:

  • 需要presentViewController遵守PresentedViewType协议即可,代码如下:
class AlertViewController: UIViewController, PresentedViewType {

    var component: PresentedViewComponent

    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        component = PresentedViewComponent(contentSize: CGSize(width: 260, height: 240))
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
    }

    required init?(coder aDecoder: NSCoder) {
        component = PresentedViewComponent(contentSize: CGSize(width: 260, height: 240))
        super.init(coder: aDecoder)
    }
}
  • 要自定义转场效果及其他,只需要设置component即可:
    ....

    let alertVC = getAlertVC()
    var component = PresentedViewComponent(contentSize: CGSize(width: 260, height: 240))
    component.destination = .center
    component.presentTransitionType = .custom(animation: CrossZoomAnimation(scale: 0.01, options: .spring(duration: 0.5, delay: 0, damping: 0.4, velocity: 10), origin: .center))
    component.dismissTransitionType = .crossZoom
    component.keyboardTranslationType = .compressInputView
    component.keyboardPadding = 60
    alertVC.component = component
    presentViewController(alertVC)

    ....

更具体的用法请下载 Demo查看。

“iOS基于UIPresentationController的封装”的回复:

  1. Every weekend i used to pay a quick visit this site, as i wish for enjoyment, since this this website conations truly fastidious funny data too. Phaidra Stewart Fremont

  2. Every weekend i used to visit this web page, because i want enjoyment, as this this site conations in fact fastidious funny information too. Ninette Gottfried Desdamonna

  3. You completed some fine points there. I did a search on the subject and found nearly all folks will have the same opinion with your blog. Kristine Ramsey Barb

torrent进行回复 取消回复

邮箱地址不会被公开。 必填项已用*标注