DKCarouselView is a automatically & circular infinite(or not) scrolling view.The view auto paging/pause can be specified as well.
$ pod search DKCarouselView
-> DKCarouselView (1.4.6)
A automatically & circular infinite scrolling view.
pod 'DKCarouselView', '~> 1.3.0'
- Homepage: https://github.com/zhangao0086/DKCarouselView
- Source: https://github.com/zhangao0086/DKCarouselView.git
- Versions: 1.0.1 [master repo]
Edit your Podfile and add DKCarouselView:
pod 'DKCarouselView', '~> x.x.x'
Add #import "DKCarouselView.h"
to the top of classes that will use it.
DKCarouselView *carouselView = [[DKCarouselView alloc] initWithFrame:CGRectMake(0, 0, 320,220)];
NSArray *images = @[@"https://c1.staticflickr.com/9/8428/7855079606_5fc8852562_z.jpg",
@"http://upload.wikimedia.org/wikipedia/commons/thumb/8/8f/Parang_mountain_image_1.jpg/640px-Parang_mountain_image_1.jpg",
@"http://www.openjpeg.org/samples/Bretagne1.bmp",
@"http://blog.absolutvision.com/wp-content/uploads/2009/10/Gimp_2.6b.jpg"
];
NSMutableArray *items = [NSMutableArray new];
for (NSString *imageUrl in images) {
DKCarouselURLItem *urlAD = [DKCarouselURLItem new];
urlAD.imageUrl = imageUrl;
[items addObject:urlAD];
}
[carouselView setItems:items];
[carouselView setAutoPagingForInterval:5];
carouselView.defaultImage = [UIImage imageNamed:@"DefaultImage"];
[self.carouselView setItemClickedBlock:^(DKCarouselItem *item, NSInteger index) {
NSLog(@"%zd",index);
}];
[self.carouselView setItemPagedBlock:^(DKCarouselView *view, NSInteger index) {
NSLog(@"%@, %zd", view, index);
}];
// set infinite slide or not, defaults to NO.
@property (nonatomic, assign, getter = isFinite) BOOL finite;
@property (nonatomic, strong) UIColor *indicatorTintColor;
@property (nonatomic, assign) CGPoint indicatorOffset; // default offset is CGPointZero, the indicator is centered horizontally.
@property (nonatomic, readonly) CGSize indicatorSize; // returns minimum size for given items.
/**
* Online Image
*/
@interface DKCarouselURLItem : DKCarouselItem
@property (nonatomic, copy) NSString *imageUrl;
@end
/**
* Custom View
*/
@interface DKCarouselViewItem : DKCarouselItem
@property (nonatomic, strong) UIView *view;
@end
This code is distributed under the terms and conditions of the MIT license