A custom UICollectionView layout which resembles a spinning roulette wheel. The cells are laid out on an invisible wheel and the wheel spins by scrolling horizontally.
This custom layout is based on the article by Rounak Jain. Thanks for the awesome article and work. The article is available here: http://www.raywenderlich.com/107687/uicollectionview-custom-layout-tutorial-spinning-wheel
Add the ARNRouletteWheelView to your UIViewController, overwrite the default cell with your custom ARNRouletteWheelCell subclass and optionally tweak the settings like wheel radius, the spacing between items and the size of the items.
To have a full screen ARNRouletteWheelView:
ARNRouletteWheelView *rouletteWheelView = [[ARNRouletteWheelView alloc] initWithFrame:self.view.frame];
rouletteWheelView.dataSource = self;
// overwrite default cell with a custom subcell
[rouletteWheelView registerClass:[ARNPosterCell class] forCellWithReuseIdentifier:@"ARNPosterCell"];
// custom settings
// [rouletteWheelView setRadius:2000.0f];
// [rouletteWheelView setInterItemSpacing:1.5f];
// [rouletteWheelView setItemSize:CGSizeMake(100.0f, 100.0f)];
[self.view addSubview:rouletteWheelView];
Your custom ARNRouletteWheelCell subclass could look like this:
@interface ARNPosterCell ()
@property (nonatomic, strong) UIImageView *imageView;
@end
@implementation ARNPosterCell
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
_imageView.clipsToBounds = YES;
_imageView.contentMode = UIViewContentModeScaleAspectFill;
[self.contentView addSubview:_imageView];
}
return self;
}
- (void)setImage:(UIImage *)image {
if (image != nil) {
[self.imageView setImage:image];
}
}
@end
To run the example project, clone the repo, and run pod install
from the Example directory first.
- ARC
- iOS7
ARNRouletteWheelView is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "ARNRouletteWheelView"
Stefan Arn
ARNRouletteWheelView is available under the MIT license. See the LICENSE file for more info.