Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix contentinset bug #99

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions PullToRefresh/PullToRefresh.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ extension PullToRefresh {
var offset: CGFloat
switch position {
case .top:
offset = previousScrollViewOffset.y + scrollViewDefaultInsets.top
offset = previousScrollViewOffset.y

case .bottom:
if scrollView!.contentSize.height > scrollView!.bounds.height {
Expand Down Expand Up @@ -272,7 +272,6 @@ private extension PullToRefresh {
return
}

scrollView.contentOffset = previousScrollViewOffset
scrollView.bounces = false
UIView.animate(
withDuration: 0.3,
Expand Down Expand Up @@ -322,7 +321,7 @@ private extension PullToRefresh {
var isCurrentlyVisible: Bool {
guard let scrollView = scrollView else { return false }

return scrollView.normalizedContentOffset.y <= -scrollViewDefaultInsets.top
return scrollView.normalizedContentOffset.y <= 0
}

func bringRefreshViewToSuperview() {
Expand Down
2 changes: 1 addition & 1 deletion PullToRefreshDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

tableView.contentInset = UIEdgeInsets(top: 100, left: 0, bottom: 0, right: 0)
setupPullToRefresh()
}

Expand Down