Compare commits

..

1 Commits

Author SHA1 Message Date
Ivan Vorobei bc998622eb Update to 1.6.8
Fix scroll indicator position
2019-07-05 23:21:44 +03:00
6 changed files with 27 additions and 8 deletions
@@ -23,15 +23,14 @@ 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)
}
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 +73,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) {
@@ -74,7 +74,7 @@ extension ModalTableViewController: UITableViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView == self.tableView {
SPStorkController.scrollViewDidScroll(scrollView)
SPStorkController.scrollViewDidScroll(scrollView, indicatorInset: self.navBar.height)
}
}
}
+6
View File
@@ -263,6 +263,12 @@ func scrollViewDidScroll(_ scrollView: UIScrollView) {
}
```
If you use vertical indicator for your scroll view, for best result pass your top inset to function. Parametr optional:
```swift
SPStorkController.scrollViewDidScroll(scrollView, indicatorInset: 25)
```
### Working with UITableView & UICollectionView
Working with a collections classes is not difficult. In the `Example` folder you can find an implementation. However, I will give a couple of tips for making the table look better.
+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.8"
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,15 @@
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.scrollIndicatorInsets.top = (indicatorInset ?? 0) + translation
presentationController.setIndicator(style: scrollView.isTracking ? .line : .arrow)
if translation >= presentationController.translateForDismiss * 0.4 {
if !scrollView.isTracking && !scrollView.isDragging {