MMTransition
描述
- 使用UIPresentationController和UIViewControllerTransitioningDelegate的自定义PresentmodaController,提供更便捷的自定义对话框或菜单
- 更多便利来自定义您的对话框或菜单
演示
要求
iOS 8.0+
Xcode 8.0+
Swift 3.0+
使用(菜单/对话框)
1.将其添加到您的Present Controller中
class DialogViewController: UIViewController {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.mmT.present.dialog { (config) in
config.animateType = .scale(from: 0, to: 1)
config.dialogType = .size(s: CGSize(width: 300, height: 200))
}
}
}
2.用代码初始化
let story = UIStoryboard.init(name: "Main", bundle: nil)
let second = story.instantiateViewController(withIdentifier: "Second")
second.mmT.present.menu { (config) in
config.isDraggable = true
config.presentingScale = 1.0
config.menuType = .bottomHeight(h: 200)
}
self.present(second, animated: true, completion: nil)
使用(pass view)
1. 在你想要传递视图的地方使用PassViewFromProtocol
// Thsis is you passView
var passView: UIView { get }
// when transition dismiss or popView you need reset your UI
func completed(passView: UIView,superV: UIView)
2. 在目标控制器上使用PassViewToProtocol
//your pass view's superView
var containerView: UIView { get }
// Thsis two method can let you get view from previous controller
// you need set your constraint when transition completed
func transitionWillStart(passView: UIView)
func transitionCompleted(passView: UIView)
在activity闭包中设置参数
vc.mmT.present.menu { (config) in
config.isDraggable = true
config.presentingScale = 1.0
......
....
..
}
样式
1. 公共参数
// presenting scale when present
public var presentingScale: CGFloat
// present controller animate damping
public var damping: CGFloat
// present controller animate option
public var animationOption: UIViewAnimationOptions
// present controller animate springVelocity
public var springVelocity: CGFloat
// present controller duration
public var duration: TimeInterval
1. 菜单参数
let menu = MMAnimator<MenuConfig>()
1.Menu Type
public var menuType:MenuTypepe
public enum MenuType {
case leftWidth(w: CGFloat)
case leftWidthFromViewRate(rate: CGFloat)
case rightWidth(w: CGFloat)2
case rightWidthFromViewRate(rate: CGFloat)
case bottomHeight(h: CGFloat)
case bottomHeightFromViewRate(rate: CGFloat)
case leftFullScreen
case rightFullScreen
}
2.Set Drag
public var isDraggable:Bool
2. 对话框参数
let dialog = MMAnimator<DialogConfig>()
1.Dialog type
public var dialogType:DialogType
public enum DialogType {
case preferSize //Xib use
case size(s:CGSize) //Custom Size
}
2.Animate Type
public var animateType:DialogAnimateType
public enum DialogAnimateType {
case alpha(from:CGFloat , to:CGFloat)
case scale(from:CGFloat , to:CGFloat)
case direction(type:DirectionType)
}
public enum DirectionType {
case left
case right
case top
case bottom
}
安装
MMTransition可以通过CocoaPods安装。要安装它,只需在Podfile中添加以下行
pod 'MMTransition'
pod 'MMTransition', '1.0.0'
ex. if you can't see command (pod repo update) in terminal
作者
许可
MMTransition遵循MIT许可。有关更多信息,请参阅LICENSE文件。