修改车辆监控细节
This commit is contained in:
@@ -11,25 +11,30 @@ open class DDUIPanGestureRecognizer : UIPanGestureRecognizer {
|
||||
case bottom,top
|
||||
}
|
||||
|
||||
|
||||
public enum ExpandLevel {
|
||||
case min,`default`,max
|
||||
}
|
||||
|
||||
public struct PanGesValue {
|
||||
public var from : PanGestureFromType = .bottom /// 从什么位置弹出
|
||||
public var minDisplayHeight : CGFloat = 0 /// 最小显示的高度
|
||||
public var defaultDisplayHeight : CGFloat = 0 /// 默认弹出的高度
|
||||
public var maxDisplayHeight : CGFloat = 0 /// 最大显示的高度
|
||||
public var criticalValue : CGFloat? /// 标记当前需要完全展开时的临界值
|
||||
public var expandLevel : ExpandLevel = .min /// 标记当前是否是展开的状态
|
||||
/// 从什么位置弹出
|
||||
public var from : PanGestureFromType = .bottom
|
||||
/// 最小显示的高度
|
||||
public var minDisplayHeight : CGFloat = 0
|
||||
/// 默认弹出的高度
|
||||
public var defaultDisplayHeight : CGFloat = 0
|
||||
/// 最大显示的高度
|
||||
public var maxDisplayHeight : CGFloat = 0
|
||||
/// 标记当前需要完全展开时的拖动比例(0,1]
|
||||
public var dragScale : CGFloat = 0.5
|
||||
/// 标记当前是否是展开的状态
|
||||
public var expandLevel : ExpandLevel = .min
|
||||
|
||||
internal var translationY : CGFloat = 0
|
||||
internal var currentY : CGFloat = 0
|
||||
}
|
||||
|
||||
public var panGesValue = PanGesValue.init()
|
||||
|
||||
|
||||
/// 会执行默认方法
|
||||
/// - Parameter target: target
|
||||
public init() {
|
||||
@@ -43,7 +48,7 @@ open class DDUIPanGestureRecognizer : UIPanGestureRecognizer {
|
||||
}
|
||||
|
||||
@objc fileprivate func panGesAction(ges: DDUIPanGestureRecognizer) {
|
||||
getBaseValue(duration: 0.1) { viewFrame, minY, defaultY, maxY, currentY in
|
||||
baseAction(duration: 0.1) { viewFrame, minY, defaultY, maxY, currentY in
|
||||
switch ges.state {
|
||||
case .began:
|
||||
currentY = viewFrame.origin.y
|
||||
@@ -57,15 +62,22 @@ open class DDUIPanGestureRecognizer : UIPanGestureRecognizer {
|
||||
currentY = (viewFrame.origin.y) + deltaY
|
||||
break
|
||||
case .ended:
|
||||
/// 当拖动的距离到达某个值时就完全显示
|
||||
let criticalValue = ges.panGesValue.criticalValue ?? (ges.panGesValue.maxDisplayHeight / 2)
|
||||
let criticalY = maxY - criticalValue
|
||||
|
||||
if ges.panGesValue.currentY < criticalY {
|
||||
currentY = minY
|
||||
}else{
|
||||
/// 当currentY在maxY和defaultY之间时的临界值
|
||||
let criticalYBetweenOfMaxYAndDefaultY = maxY - (maxY - defaultY) * ges.panGesValue.dragScale
|
||||
if ges.panGesValue.currentY <= maxY && ges.panGesValue.currentY > criticalYBetweenOfMaxYAndDefaultY {
|
||||
currentY = maxY
|
||||
}else if ges.panGesValue.currentY > defaultY && ges.panGesValue.currentY <= criticalYBetweenOfMaxYAndDefaultY {
|
||||
currentY = defaultY
|
||||
}
|
||||
|
||||
/// 当currentY在minY和defaultY之间时
|
||||
let criticalYBetweenOfMinYAndDefaultY = defaultY - (defaultY - minY) * ges.panGesValue.dragScale
|
||||
if ges.panGesValue.currentY <= defaultY && ges.panGesValue.currentY > criticalYBetweenOfMinYAndDefaultY {
|
||||
currentY = defaultY
|
||||
}else if ges.panGesValue.currentY > minY && ges.panGesValue.currentY <= criticalYBetweenOfMinYAndDefaultY {
|
||||
currentY = minY
|
||||
}
|
||||
|
||||
ges.panGesValue.translationY = 0
|
||||
break
|
||||
default:
|
||||
@@ -75,7 +87,7 @@ open class DDUIPanGestureRecognizer : UIPanGestureRecognizer {
|
||||
}
|
||||
}
|
||||
|
||||
func getBaseValue(duration: TimeInterval,baseValueHandler: (_ viewFrame: CGRect, _ minY: CGFloat, _ defaultY: CGFloat, _ maxY: CGFloat,_ currentY: inout CGFloat) -> Void) {
|
||||
func baseAction(duration: TimeInterval,baseActionHandler: (_ viewFrame: CGRect, _ minY: CGFloat, _ defaultY: CGFloat, _ maxY: CGFloat,_ currentY: inout CGFloat) -> Void) {
|
||||
guard let superView = view?.superview else {
|
||||
assert(false,"父类都没有,拖什么拖")
|
||||
return
|
||||
@@ -110,7 +122,7 @@ open class DDUIPanGestureRecognizer : UIPanGestureRecognizer {
|
||||
var currentY : CGFloat = 0.0
|
||||
|
||||
/// 计算值
|
||||
baseValueHandler(viewFrame,minY,defaultY,maxY,¤tY)
|
||||
baseActionHandler(viewFrame,minY,defaultY,maxY,¤tY)
|
||||
|
||||
/// 当到达最小y值时返回
|
||||
if currentY < minY {
|
||||
@@ -122,8 +134,10 @@ open class DDUIPanGestureRecognizer : UIPanGestureRecognizer {
|
||||
return
|
||||
}
|
||||
|
||||
/// 记录当前的currentY
|
||||
panGesValue.currentY = currentY
|
||||
|
||||
/// 记录当前的expandLevel
|
||||
if panGesValue.currentY == minY {
|
||||
panGesValue.expandLevel = .max
|
||||
}else if panGesValue.currentY == maxY {
|
||||
@@ -142,7 +156,7 @@ open class DDUIPanGestureRecognizer : UIPanGestureRecognizer {
|
||||
}
|
||||
|
||||
public func expand(_ expand: ExpandLevel) {
|
||||
getBaseValue(duration: 0.25) { viewFrame, minY, defaultY, maxY, currentY in
|
||||
baseAction(duration: 0.25) { viewFrame, minY, defaultY, maxY, currentY in
|
||||
if expand == .max {
|
||||
currentY = minY
|
||||
}else if expand == .min {
|
||||
@@ -153,14 +167,3 @@ open class DDUIPanGestureRecognizer : UIPanGestureRecognizer {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension UIView {
|
||||
public func addPanGesture(from: DDUIPanGestureRecognizer.PanGestureFromType, minDisplayHeight: CGFloat, maxDisplayHeight: CGFloat, criticalValue: CGFloat? = nil) {
|
||||
let pan = DDUIPanGestureRecognizer.init()
|
||||
pan.panGesValue.from = from
|
||||
pan.panGesValue.minDisplayHeight = minDisplayHeight
|
||||
pan.panGesValue.maxDisplayHeight = maxDisplayHeight
|
||||
pan.panGesValue.criticalValue = criticalValue
|
||||
addGestureRecognizer(pan)
|
||||
}
|
||||
}
|
||||
|
||||
12
Pods/Manifest.lock
generated
12
Pods/Manifest.lock
generated
@@ -283,9 +283,9 @@ PODS:
|
||||
- DDTimerSwiftKit_Private (0.2.1):
|
||||
- DDLogKit_Private/SwiftLog
|
||||
- DDToastKit_Private (0.1.2)
|
||||
- DDUIGestureRecognizer (0.1.4):
|
||||
- DDUIGestureRecognizer/DDUIPanGestureRecognizer (= 0.1.4)
|
||||
- DDUIGestureRecognizer/DDUIPanGestureRecognizer (0.1.4)
|
||||
- DDUIGestureRecognizer (0.1.5):
|
||||
- DDUIGestureRecognizer/DDUIPanGestureRecognizer (= 0.1.5)
|
||||
- DDUIGestureRecognizer/DDUIPanGestureRecognizer (0.1.5)
|
||||
- DDUtilsSwiftKit_Private (0.1.1):
|
||||
- DDUtilsSwiftKit_Private/ApplicationInfo (= 0.1.1)
|
||||
- DDUtilsSwiftKit_Private/DeviceInfo (= 0.1.1)
|
||||
@@ -352,7 +352,7 @@ DEPENDENCIES:
|
||||
- DDProgressHUDKit_Private
|
||||
- DDTimerSwiftKit_Private
|
||||
- DDToastKit_Private
|
||||
- DDUIGestureRecognizer (= 0.1.4)
|
||||
- DDUIGestureRecognizer (= 0.1.5)
|
||||
- DDUtilsSwiftKit_Private
|
||||
- DDWebImageKit_Private
|
||||
- DDZFPlayerKit_Private/ControlView
|
||||
@@ -441,7 +441,7 @@ SPEC CHECKSUMS:
|
||||
DDProgressHUDKit_Private: 1e219062ddeb7801a4bb13b367efa1f3fbf17f1e
|
||||
DDTimerSwiftKit_Private: cce3fe58b1b581fe4cddb3fb84fcde31b4e83541
|
||||
DDToastKit_Private: b6ae3709d110cadca503a037419f3709d1755256
|
||||
DDUIGestureRecognizer: 207a58f9c0123664ff8d9d323d94e1481975b696
|
||||
DDUIGestureRecognizer: e7b1b6d4d73e2fc2c48dcfb38655881814d094ff
|
||||
DDUtilsSwiftKit_Private: 03575cb3204cd43f3521049263f4b6cae3e64700
|
||||
DDWebImageKit_Private: b905111547e44626773b729bae9030403a9a0c76
|
||||
DDZFPlayerKit_Private: 5f63a8101e35ffd7b2568f551cbf33b8bedc48ba
|
||||
@@ -461,6 +461,6 @@ SPEC CHECKSUMS:
|
||||
SwiftyRSA: 8c6dd1ea7db1b8dc4fb517a202f88bb1354bc2c6
|
||||
ZLPhotoBrowser: 0563c2bfc7b247b65d023d646012f46cba94101b
|
||||
|
||||
PODFILE CHECKSUM: b8d52ee7c2693a0587d0eddb0f63d9e164d97c2d
|
||||
PODFILE CHECKSUM: 42053b92ac9e24ed76797463ba14cc31e3771ffc
|
||||
|
||||
COCOAPODS: 1.11.3
|
||||
|
||||
Reference in New Issue
Block a user