TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | Custom |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
Implement a paginated scroll view really easily using blocks.
- (NSInteger)currentPage
- (NSInteger)nextPage
- (NSInteger)lastPage
- (NSInteger)numberOfPages
- (void)addPageWithHandler:(void (^)(UIView * pageView))handler
handler
is a block passing the view that will contain the subviews for the new page, so in that block you just need to add all the views to be displayed on that page to the pageView
. It'll just work.Applying autolayout on the subviews is not obligatory, but recommended.
Anyway, if you decide to use autolayout I suggest using a framework called Masonry. Pretty great stuff.
Here's an example without using autolayout, to simplify things. If you want to see an example of this implementation using autolayout, check out the demo app:
[paginatedScrollView addPageWithHandler:^(UIView * pageView) {
UIView * square = [UIView new];
[square setBackgroundColor:[UIColor redColor]];
[square setFrame:CGRectMake(0, 0, 100, 100)];
[pageView addSubview:square];
}];
- (void)jumpToPage:(NSInteger)page bounce:(CGFloat)bounce completion:(void (^)(void))completion
page
specifies the index of the page to jump.bounce
specifies the amount of bouncy effect the jump will be performed with. Recommended values are 0
-40
, being 0 the total absence of bounce.completion
is a block that will be executed after the jump is performed.Here are some examples:
// Jumping to the 4th page with no bounce effect and completion
[paginatedScrollView jumpToPage:3 bounce:0 completion:^{
NSLog(@"Jump finished!");
}];
// Jumping to the first page with a normal bounce effect and no completion
[paginatedScrollView jumpToPage:0 bounce:20 completion:nil];
// Jumping to the next page with a little bounce effect and no completion
[paginatedScrollView jumpToPage:[paginatedScrollView nextPage] bounce:10 completion:nil];
// Jumping to the last page with a high bounce effect and no completion
[paginatedScrollView jumpToPage:[paginatedScrollView lastPage] bounce:40 completion:nil];
BOOL isJumping
NSTimeInterval jumpDurationPerPage
0.1
0.05
-0.175
void (^actionWhenTappedBlock)(DRPaginatedScrollView *)
Default value:
^(DRPaginatedScrollView * paginatedScrollView) {
[paginatedScrollView jumpToPage:[paginatedScrollView nextPage] bounce:0 completion:nil];
}
paginatedScrollView configurePageIndicatorWithHandler:
).pageView clipSubview:untilPage:
) and forever (pageView clipSubviewForever:
).No contributors, yet.
You can use it for whatever you want, however you want. I just would love to know if you're using it in any project of yours.