Compare commits

..

2 Commits

Author SHA1 Message Date
Ivan Vorobei 7381066b36 Update to 1.6.9 2019-07-05 23:33:54 +03:00
Ivan Vorobei bc998622eb Update to 1.6.8
Fix scroll indicator position
2019-07-05 23:21:44 +03:00
4 changed files with 28 additions and 5 deletions
@@ -23,15 +23,19 @@ import UIKit
public enum SPStorkController {
static public func scrollViewDidScroll(_ scrollView: UIScrollView) {
static public func scrollViewDidScroll(_ scrollView: UIScrollView, indicatorInset: CGFloat? = nil) {
if let controller = self.controller(for: scrollView) {
if let presentationController = controller.presentationController as? SPStorkPresentationController {
if let presentationController = self.presentationController(for: controller) {
let translation = -(scrollView.contentOffset.y + scrollView.contentInset.top)
if translation >= 0 {
if controller.isBeingPresented { return }
scrollView.subviews.forEach {
$0.transform = CGAffineTransform(translationX: 0, y: -translation)
}
/* Maybe migrate to it in future. Bug with bottom safe area
scrollView.transform = CGAffineTransform(translationX: 0, y: -translation)
scrollView.scrollIndicatorInsets.top = (indicatorInset ?? 0) + translation
*/
presentationController.setIndicator(style: scrollView.isTracking ? .line : .arrow)
if translation >= presentationController.translateForDismiss * 0.4 {
if !scrollView.isTracking && !scrollView.isDragging {
@@ -74,6 +78,18 @@ public enum SPStorkController {
}
}
static private func presentationController(for controller: UIViewController) -> SPStorkPresentationController? {
if let presentationController = controller.presentationController as? SPStorkPresentationController {
return presentationController
}
if let presentationController = controller.parent?.presentationController as? SPStorkPresentationController {
return presentationController
}
return nil
}
static private func controller(for view: UIView) -> UIViewController? {
var nextResponder = view.next
while nextResponder != nil && !(nextResponder! is UIViewController) {
+1 -1
View File
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "SPStorkController"
s.version = "1.6.7"
s.version = "1.6.9"
s.summary = "Very similar to the controllers displayed in Apple Music, Podcasts and Mail Apple's applications."
s.homepage = "https://github.com/IvanVorobei/SPStorkController"
s.source = { :git => "https://github.com/IvanVorobei/SPStorkController.git", :tag => s.version }
@@ -22,13 +22,20 @@
import UIKit
public enum SPStorkController {
static public func scrollViewDidScroll(_ scrollView: UIScrollView) {
static public func scrollViewDidScroll(_ scrollView: UIScrollView, indicatorInset: CGFloat? = nil) {
if let controller = self.controller(for: scrollView) {
if let presentationController = self.presentationController(for: controller) {
let translation = -(scrollView.contentOffset.y + scrollView.contentInset.top)
if translation >= 0 {
if controller.isBeingPresented { return }
scrollView.transform = CGAffineTransform(translationX: 0, y: -translation)
scrollView.subviews.forEach {
$0.transform = CGAffineTransform(translationX: 0, y: -translation)
}
/* Maybe migrate to it in future. Bug with bottom safe area
scrollView.transform = CGAffineTransform(translationX: 0, y: -translation)
scrollView.scrollIndicatorInsets.top = (indicatorInset ?? 0) + translation
*/
presentationController.setIndicator(style: scrollView.isTracking ? .line : .arrow)
if translation >= presentationController.translateForDismiss * 0.4 {
if !scrollView.isTracking && !scrollView.isDragging {