updated to use generic
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
0ee459946f
commit
88fdcabe67
@ -223,7 +223,7 @@ extension DatePicker {
|
||||
|
||||
//find scrollView
|
||||
if scrollView == nil {
|
||||
scrollView = findScrollView(from: containerView)
|
||||
scrollView = containerView.findSuperview(ofType: UIScrollView.self)
|
||||
scrollViewContentSize = scrollView?.contentSize
|
||||
}
|
||||
|
||||
@ -348,17 +348,6 @@ extension DatePicker {
|
||||
}
|
||||
}
|
||||
|
||||
private func findScrollView(from view: UIView) -> UIScrollView? {
|
||||
var currentView = view
|
||||
while let superview = currentView.superview {
|
||||
if let scrollView = superview as? UIScrollView {
|
||||
return scrollView
|
||||
}
|
||||
currentView = superview
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
private func calculatePopoverPosition(relativeTo sourceView: UIView, in parentView: UIView, size: CGSize, with spacing: CGFloat) -> CGPoint? {
|
||||
let sourceFrameInParent = sourceView.convert(sourceView.bounds, to: parentView)
|
||||
let parentBounds = parentView.bounds
|
||||
@ -442,3 +431,16 @@ extension DatePicker {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension UIView {
|
||||
public func findSuperview<T: UIView>(ofType type: T.Type) -> T? {
|
||||
var currentView: UIView? = self
|
||||
while let view = currentView {
|
||||
if let superview = view.superview as? T {
|
||||
return superview
|
||||
}
|
||||
currentView = view.superview
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user