Home

Awesome

DKCarouselView

infinite scrolling

GIF

finite scrolling

GIF

custom view

GIF

adapting

GIF

Overview

DKCarouselView is a automatically & circular infinite(or not) scrolling view.The view auto paging/pause can be specified as well.

How To Get Started

Installation with CocoaPods

$ 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.

Create instances (Also supports xib/storyboard)
DKCarouselView *carouselView = [[DKCarouselView alloc] initWithFrame:CGRectMake(0, 0, 320,220)];
Setup items
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];
Auto paging for 5 seconds
[carouselView setAutoPagingForInterval:5];
Placeholder for online images
carouselView.defaultImage = [UIImage imageNamed:@"DefaultImage"];
Callback
[self.carouselView setItemClickedBlock:^(DKCarouselItem *item, NSInteger index) {
    NSLog(@"%zd",index);
}];
[self.carouselView setItemPagedBlock:^(DKCarouselView *view, NSInteger index) {
    NSLog(@"%@, %zd", view, index);
}];
Finite or not
// set infinite slide or not, defaults to NO.
@property (nonatomic, assign, getter = isFinite) BOOL finite;
Indicator style
@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.
DKCarouselURLItem Or DKCarouselViewItem
/**
 *  Online Image
 */
@interface DKCarouselURLItem : DKCarouselItem

@property (nonatomic, copy) NSString *imageUrl;

@end

/**
 *  Custom View
 */
@interface DKCarouselViewItem : DKCarouselItem

@property (nonatomic, strong) UIView *view;

@end

License

This code is distributed under the terms and conditions of the <a href="https://github.com/zhangao0086/DKCarouselView/blob/master/LICENSE">MIT license</a>

Special Thanks

<a target="_blank" href="https://github.com/jiyee">jiyee</a>