Latest 0.5.0
Homepage https://github.com/wxxsw/GSRefresh
License MIT
Platforms ios 8.0, requires ARC
Authors

GSRefresh

GSRefresh
GSRefresh
GSRefresh
GSRefresh
GSRefresh
GSRefresh

Example

Refresh

Set the drop-down refresh:

scrollView.refresh.setup(view: CustomRefreshView) {
    /// do something...
    self.scrollView.refresh.endRefreshing()
}

Immediately trigger the refresh state:

scrollView.refresh.beginRefreshing()

End the refresh state:

scrollView.refresh.endRefreshing()

Custom Refresh View

extension SomeView: CustomRefresh {

    /// @optional, default is 44.
    /// Sets the height displayed when refreshing.
    var refreshingKeepHeight: CGFloat { return 44 }

    /// @optional, default is .init(top: 30, left: 0, bottom: 0, right: 0).
    /// -top: increase the trigger refresh distance.
    /// -left and right: set the horizontal offset.
    /// -bottom: increase the distance from scrollview.
    var refreshInsets: UIEdgeInsets { return .zero }

    /**
     In this method, set the UI in different states.
     There are three status types: initial, pulling, refreshing.

     - parameter previous: previous refresh state
     - parameter newState: new refresh state
    */
    func refreshStateChanged(previous: RefreshState, newState: RefreshState) {
        /// do something...
    }

}

let someView = SomeView(frame: ...)

scrollView.refresh.setup(view: someView) {
    /// do something...
    self.scrollView.refresh.endRefreshing()
}

LoadMore

Set the pull-up load:

scrollView.loadMore.setup(view: CustomLoadMoreView) {
    /// do something...
    self.scrollView.loadMore.endRefreshing(noMore: Bool)
}

Immediately trigger the refresh state:

scrollView.loadMore.beginRefreshing()

End the refresh state and set whether no longer try to load new data:

scrollView.loadMore.endRefreshing(noMore: Bool)

Reset to continue loading data:

scrollView.loadMore.reset()

No longer try to load new data:

scrollView.loadMore.noMore()

Custom LoadMore View

extension SomeView: CustomLoadMore {

    /// @optional, default is 0.
    /// Set the preload configuration, such as half screen 0.5, one screen is 1, two screens are 2, no preload is 0.
    var preload: CGFloat { get }

    /// @optional, default is true.
    /// When there is no more data, is it necessary to keep the height of the custom view? If it is false, it will not be displayed.
    var isVisibleNoMore: Bool { get }

    /// @optional, default is .zero.
    /// -top: increase the distance from scrollview.
    /// -left and right: set the horizontal offset.
    /// -bottom: increase the distance from the bottom.
    var loadMoreInsets: UIEdgeInsets { get }

    /**
     In this method, set the UI in different states.
     There are three status types: initial, refreshing, noMore.

     - parameter previous: previous load more state
     - parameter newState: new load more state
     */
    func loadMoreStateChanged(previous: LoadMoreState, newState: LoadMoreState)
        /// do something...
    }

}

let someView = SomeView(frame: ...)

scrollView.loadMore.setup(view: someView) {
    /// do something...
    self.scrollView.loadMore.endRefreshing(noMore: Bool)
}

Requirements

Master

  • iOS 8.0+
  • Xcode 10 (Swift 4.2)

0.4.7

  • iOS 8.0+
  • Xcode 9.x (Swift 4)

0.3.0

  • iOS 8.0+
  • Xcode 9.x (Swift 3.x)

Installation

CocoaPods:

In your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod "GSRefresh"

And in your *.swift:

import GSRefresh

Carthage:

In your Cartfile:

github "wxxsw/GSRefresh"

And in your *.swift:

import GSRefresh

License

GSRefresh is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "GSRefresh",
    "version": "0.5.0",
    "summary": "Fully customizable drop-down refresh and load more.",
    "homepage": "https://github.com/wxxsw/GSRefresh",
    "license": "MIT",
    "authors": {
        "Gesen": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/wxxsw/GSRefresh.git",
        "tag": "0.5.0"
    },
    "source_files": "Sources/*.swift",
    "requires_arc": true,
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This