UIScrollView(InfiniteScroll)
@interface UIScrollView (InfiniteScroll)
UIScrollView infinite scroll category
-
The direction that the infinite scroll should work in (default: InfiniteScrollDirectionVertical).
Declaration
Objective-C
@property (assign, readwrite, nonatomic) InfiniteScrollDirection infiniteScrollDirection;Swift
var infiniteScrollDirection: InfiniteScrollDirection { get set } -
Flag that indicates whether infinite scroll is animating
Declaration
Objective-C
@property (readonly, getter=isAnimatingInfiniteScroll, nonatomic) BOOL animatingInfiniteScroll;Swift
var isAnimatingInfiniteScroll: Bool { get } -
Infinite scroll activity indicator style (default: UIActivityIndicatorViewStyleGray on iOS, UIActivityIndicatorViewStyleWhite on tvOS)
Declaration
Objective-C
@property (assign, readwrite, nonatomic) UIActivityIndicatorViewStyle infiniteScrollIndicatorStyle;Swift
var infiniteScrollIndicatorStyle: UIActivityIndicatorViewStyle { get set } -
Infinite indicator view
You can set your own custom view instead of default activity indicator, make sure it implements methods below:
- (void)startAnimating- (void)stopAnimating
Infinite scroll will call implemented methods during user interaction.
Declaration
Objective-C
@property (assign, readwrite, nonatomic, nullable) UIView *infiniteScrollIndicatorView;Swift
var infiniteScrollIndicatorView: UIView? { get set } -
The margin from the scroll view content to the indicator view (Default: 11)
Declaration
Objective-C
@property (assign, readwrite, nonatomic) CGFloat infiniteScrollIndicatorMargin;Swift
var infiniteScrollIndicatorMargin: CGFloat { get set } -
Set adjustment for scroll coordinate used to determine when to call handler block. Non-zero value advances the point when handler block is being called making it fire by N points earlier before scroll view reaches the bottom or right edge. This value is measured in points and must be positive number. Default: 0.0
Declaration
Objective-C
@property (assign, readwrite, nonatomic) CGFloat infiniteScrollTriggerOffset;Swift
var infiniteScrollTriggerOffset: CGFloat { get set } -
Setup infinite scroll handler
Declaration
Objective-C
- (void)addInfiniteScrollWithHandler: (nonnull void (^)(UIScrollView *_Nonnull))handler;Swift
func addInfiniteScroll(handler: @escaping (UIScrollView) -> Void)Parameters
handlera handler block
-
Set a handler to be called to check if the infinite scroll should be shown
Declaration
Objective-C
- (void)setShouldShowInfiniteScrollHandler: (nullable BOOL (^)(UIScrollView *_Nonnull))handler;Swift
func setShouldShowInfiniteScrollHandler(_ handler: ((UIScrollView) -> Bool)?)Parameters
handlera handler block
-
Unregister infinite scroll
Declaration
Objective-C
- (void)removeInfiniteScroll;Swift
func removeInfiniteScroll() -
Manually begin infinite scroll animations
This method provides identical behavior to user initiated scrolling.
Declaration
Objective-C
- (void)beginInfiniteScroll:(BOOL)forceScroll;Swift
func beginInfiniteScroll(_ forceScroll: Bool)Parameters
forceScrollpass YES to scroll to indicator view
-
Finish infinite scroll animations
You must call this method from your infinite scroll handler to finish all animations properly and reset infinite scroll state
Declaration
Objective-C
- (void)finishInfiniteScrollWithCompletion: (nullable void (^)(UIScrollView *_Nonnull))handler;Swift
func finishInfiniteScroll(completion handler: ((UIScrollView) -> Void)? = nil)Parameters
handlera completion block handler called when animation finished
-
Finish infinite scroll animations
You must call this method from your infinite scroll handler to finish all animations properly and reset infinite scroll state
Declaration
Objective-C
- (void)finishInfiniteScroll;Swift
func finishInfiniteScroll()
View on GitHub
UIScrollView(InfiniteScroll) Category Reference