Skip to content

TernTuring/TernBannerView

Repository files navigation

TernBannerView

Example

Requirements

  • iOS 9.0+
  • Xcode 10.0+

Installation

Use CocoaPods with Podfile:

pod 'TernBannerView'

Features

  • self-customized the banner Height
  • Infinite loop scrolling view
  • Support Autolayout
  • Supports whether PageController is displayed

Usage

  1. 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 ]];
  1. Implement TernBannerViewDelegate delegate in your class:
- (void)bannerView:(TernBannerView *)bannerView didSelectItemAtIndex:(NSInteger)index {

}
  1. Implement TernBannerViewDataSource datasource in your class:
- (NSInteger)numberItemsOfBanner:(TernBannerView *)bannerView {
    return 4;
}

- (UIImage *)bannerView:(TernBannerView *)bannerView cellForItemAtIndex:(NSInteger)index {
    return [UIImage imageNamed:@"banner.png"];
}

Licence

TernBannerView is released under the MIT license. See LICENSE for details.

About

A very simple implementation of a Infinite loop scrolling view on iOS.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors