forked from AlvaroFranco/AFScrollView
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAFScrollView.m
More file actions
47 lines (33 loc) · 1.1 KB
/
Copy pathAFScrollView.m
File metadata and controls
47 lines (33 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// AFScrollView.m
// AFScrollView
//
// Created by Alvaro Franco on 3/13/14.
// Copyright (c) 2014 AlvaroFranco. All rights reserved.
//
#import "AFScrollView.h"
@interface AFScrollView ()
@property (nonatomic) NSInteger numberOfPages;
@end
@implementation AFScrollView
-(id)initWithFrame:(CGRect)frame andNumberOfPages:(NSInteger)pages {
self = [super initWithFrame:frame];
if (self) {
self.contentSize = CGSizeMake(pages * self.bounds.size.width, self.bounds.size.height);
_numberOfPages = pages;
}
return self;
}
-(void)configureViewAtIndexWithCompletion:(configurationBlock)completion {
if (!_numberOfPages) {
NSLog(@"AFScrollView message: A valid number of views must be provided");
completion(nil, 0, NO);
} else {
for (int i = 0; i < _numberOfPages; i++) {
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(self.bounds.size.width * i, 0, self.bounds.size.width, self.bounds.size.height)];
[self addSubview:view];
completion(view, i, YES);
}
}
}
@end