Latest 1.0.2
Homepage https://github.com/songyutao/YTCarouselView
License MIT
Platforms ios 7.0, requires ARC
Authors

A carousel control allows you to customize each rotation view freely.

Examples:

Initialization

YTCarouselView *carouselView = [[YTCarouselView alloc] initWithFrame:CGRectMake(0, 100, self.view.bounds.size.width, 180)];
carouselView.delegate = (id<YTCarouselViewDelegate>)self;
[carouselView reloadData];
[self.view addSubview:carouselView];

Delegate

#pragma - mark - YTCarouselViewDelegate
- (NSUInteger)numberOfLoopImageView:(YTCarouselView *)loopImageView
{
    return 4;
}

- (UIView *)loopImageView:(YTCarouselView *)loopImageView viewForIndex:(NSUInteger)index
{
    int R = (arc4random() % 256) ;
    int G = (arc4random() % 256) ;
    int B = (arc4random() % 256) ;

    UIColor *color = [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:1];

    switch (index) {
        case 1:
        {
            UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, loopImageView.bounds.size.width, loopImageView.bounds.size.height)];
            view.backgroundColor = color;
            UIButton *button = [UIButton buttonWithType:0];
            ];
            ;
            ;
            ;
            [view addSubview:button];
            return view;
            break;
        }
        case 2:
        {
            NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://img07.tooopen.com/images/20170818/tooopen_sy_220999936848.jpg"] options:NSDataReadingUncached error:nil];
            UIImage *image = [UIImage imageWithData:data];
            UIImageView *view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, loopImageView.bounds.size.width, loopImageView.bounds.size.height)];
            view.backgroundColor = color;
            [view setImage:image];
            return view;
            break;
        }
        default:
        {
            UILabel *view = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, loopImageView.bounds.size.width, loopImageView.bounds.size.height)];
            view.backgroundColor = color;
            view.text = [NSString stringWithString:[@(index) stringValue]];
            view.textAlignment = NSTextAlignmentCenter;
            return view;
        }

    }
}

- (void)didSelected:(YTCarouselView *)loopImageView forIndex:(NSUInteger)index
{
    NSLog(@"%ld", index);
}

Demo

YTCarouselView

Latest podspec

{
    "name": "YTCarouselView",
    "platforms": {
        "ios": "7.0"
    },
    "version": "1.0.2",
    "license": "MIT",
    "summary": "a custom carousel view",
    "homepage": "https://github.com/songyutao/YTCarouselView",
    "authors": {
        "u5b8bu7389u6d9b": "[email protected]"
    },
    "source": {
        "git": "https://github.com/songyutao/YTCarouselView.git",
        "tag": "1.0.2"
    },
    "requires_arc": true,
    "subspecs": [
        {
            "name": "YTCarouselView",
            "source_files": "YTCarouselView/YTCarouselView",
            "dependencies": {
                "YTTool": []
            },
            "frameworks": [
                "UIKit"
            ]
        }
    ]
}

Pin It on Pinterest

Share This