- iOS 9.0+
- Xcode 10.0+
Use CocoaPods with Podfile:
pod 'TernBannerView'
- self-customized the banner Height
- Infinite loop scrolling view
- Support Autolayout
- Supports whether PageController is displayed
- Init View:
TernBannerView *banner = [[TernBannerView alloc] init:TernBannerDataImage];
banner.delegate = self;
banner.dataSource = self;
banner.showPageController = YES;
banner.bannerHeight = 160;
banner.autoLoop = YES;
[banner setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.view addSubview:banner];
NSDictionary *constraintsView = NSDictionaryOfVariableBindings(banner);
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-50-[banner(160)]" options:0 metrics:nil views:constraintsView ]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[banner]-0-|" options:0 metrics:nil views:constraintsView ]];- Implement
TernBannerViewDelegatedelegate in your class:
- (void)bannerView:(TernBannerView *)bannerView didSelectItemAtIndex:(NSInteger)index {
}- Implement
TernBannerViewDataSourcedatasource in your class:
- (NSInteger)numberItemsOfBanner:(TernBannerView *)bannerView {
return 4;
}
- (UIImage *)bannerView:(TernBannerView *)bannerView cellForItemAtIndex:(NSInteger)index {
return [UIImage imageNamed:@"banner.png"];
}TernBannerView is released under the MIT license. See LICENSE for details.
