项目作者: iTofu

项目描述 :
A very popular and highly customized banner view! Infinite loop support!
高级语言: Objective-C
项目地址: git://github.com/iTofu/LCBannerView.git
创建时间: 2015-11-30T08:59:15Z
项目社区:https://github.com/iTofu/LCBannerView

开源协议:MIT License

下载


LCBannerView

Travis
CocoaPods
CocoaPods
CocoaPods
LeoDev

🔥 A very popular and highly customized banner view! Infinite loop!

LCBannerView

  1. In me the tiger sniffs the rose.
  2. 心有猛虎,细嗅蔷薇。

Welcome to my blog: http://LeoDev.me

中文介绍

Introduction

This is a display of advertising or information.

You can using the images from Local or Internet.

And it won’t affect other scrollViews’ scrollsToTop properties.

If you feel good, please give me a star, thank you very much! ⭐️

Installation

CocoaPods

LCBannerView is available on CocoaPods. Just add the following to your project Podfile:

  1. pod "LCBannerView" # Podfile

Non-CocoaPods Installation

Just drag the LCBannerView folder into your project.

Usage

  • Use by including the following import:

    1. #import "LCBannerView.h"
  • Demo code:

    1. // 1. From internet
    2. [scrollView addSubview:({
    3. LCBannerView *bannerView = [LCBannerView bannerViewWithFrame:CGRectMake(0, 300.0f, [UIScreen mainScreen].bounds.size.width, 200.0f)
    4. delegate:self
    5. imageURLs:URLs
    6. placeholderImageName:nil
    7. timeInterval:2.0f
    8. currentPageIndicatorTintColor:[UIColor redColor]
    9. pageIndicatorTintColor:[UIColor whiteColor]];
    10. bannerView.pageDistance = 20.0f;
    11. bannerView;
    12. })];
    13. // 2. From local
    14. // If you using images from local, you should let images named: `banner_01@2x.png`, `banner_02@2x.png`...
    15. // Than, you just give me a image named: `banner`. 😜
    16. [scrollView addSubview:({
    17. LCBannerView *bannerView = [[LCBannerView alloc] initWithFrame:CGRectMake(0, 20.0f, [UIScreen mainScreen].bounds.size.width, 200.0f)
    18. delegate:self
    19. imageName:@"banner"
    20. count:3
    21. timeInterval:3.0f
    22. currentPageIndicatorTintColor:[UIColor orangeColor]
    23. pageIndicatorTintColor:[UIColor whiteColor]];
    24. bannerView;
    25. })];
  • Advise for run demo:

    You should comment out one of the Block code or Delegate code in demo code, it will help you read code more clearly.

    See below two points for more information.

  • Block: (@optional)

    1. @property (nonatomic, copy) LCBannerViewDidClickedImageIndexBlock didClickedImageIndexBlock;
    2. @property (nonatomic, copy) LCBannerViewDidScrollToIndexBlock didScrollToIndexBlock;

    For example:

    1. bannerView.didClickedImageIndexBlock = ^(LCBannerView *bannerView, NSInteger index) {
    2. NSLog(@"Block: Clicked image in %p at index: %d", bannerView, (int)index);
    3. };
    4. bannerView.didScrollToIndexBlock = ^(LCBannerView *bannerView, NSInteger index) {
    5. NSLog(@"Block: Scrolled in %p to index: %d", bannerView, (int)index);
    6. };
    7. // Logs
    8. 2016-07-29 15:41:00.344 LCBannerViewDemo[3251:295032] Block: Scrolled in 0x7ff473538ec0 to index: 1
    9. 2016-07-29 15:41:03.343 LCBannerViewDemo[3251:295032] Block: Scrolled in 0x7ff473538ec0 to index: 2
    10. 2016-07-29 15:41:05.132 LCBannerViewDemo[3251:295032] Block: Clicked image in 0x7ff473538ec0 at index: 2
    11. 2016-07-29 15:41:06.344 LCBannerViewDemo[3251:295032] Block: Scrolled in 0x7ff473538ec0 to index: 0
    12. 2016-07-29 15:41:09.344 LCBannerViewDemo[3251:295032] Block: Scrolled in 0x7ff473538ec0 to index: 1
    13. 2016-07-29 15:41:12.342 LCBannerViewDemo[3251:295032] Block: Scrolled in 0x7ff473538ec0 to index: 2
  • Delegate: (@optional)

    1. - (void)bannerView:(LCBannerView *)bannerView didClickedImageIndex:(NSInteger)index;
    2. - (void)bannerView:(LCBannerView *)bannerView didScrollToIndex:(NSInteger)index;

    For example:

    1. - (void)bannerView:(LCBannerView *)bannerView didClickedImageIndex:(NSInteger)index {
    2. NSLog(@"Delegate: Clicked image in %p at index: %d", bannerView, (int)index);
    3. }
    4. - (void)bannerView:(LCBannerView *)bannerView didScrollToIndex:(NSInteger)index {
    5. NSLog(@"Delegate: Scrolled in %p to index: %d", bannerView, (int)index);
    6. }
    7. // Logs
    8. 2016-07-29 15:41:45.296 LCBannerViewDemo[3293:296197] Delegate: Scrolled in 0x7f915b7349b0 to index: 1
    9. 2016-07-29 15:41:47.300 LCBannerViewDemo[3293:296197] Delegate: Scrolled in 0x7f915b7349b0 to index: 0
    10. 2016-07-29 15:41:48.429 LCBannerViewDemo[3293:296197] Delegate: Clicked image in 0x7f915b7349b0 at index: 0
    11. 2016-07-29 15:41:49.308 LCBannerViewDemo[3293:296197] Delegate: Scrolled in 0x7f915b7349b0 to index: 1
    12. 2016-07-29 15:41:51.297 LCBannerViewDemo[3293:296197] Delegate: Scrolled in 0x7f915b7349b0 to index: 0
  • Custom parameters:

    1. // Distance to bottom of pageControl. Default is `10.0f`.
    2. @property (nonatomic, assign) CGFloat pageDistance;
    3. // Not allow scrolling. Default `No`, allow scrolling.
    4. @property (nonatomic, assign) BOOL notScrolling;

ChangeLog

V 2.1.1

  • Hide pageControl support:

    1. // Hide or show pageControl. Default is `NO`, show pageControl.
    2. @property (nonatomic, assign) BOOL hidePageControl;

V 2.1.0

  • Implementation requirement: Issue 6 by skyboy1342.

    Now you could get the clicked image’s index and the index scroll to, with Block or Delegate, see Usage.

  • Calculation: didScrollToIndex method won’t be called to index 0 when you add bannerView to superView, because it hadn’t scroll at all, and in fact you know index is 0 now because you do this.

V 2.0.0 (⚠️ Important)

  • Fix Issue 5, thx MVakas!

  • Modify some of the properties’ name and methods’ name:

    1. // Properties' name.
    2. @property (nonatomic, assign) CGFloat timerInterval;
    3. ->
    4. @property (nonatomic, assign) CGFloat timeInterval;
    5. @property (nonatomic, copy ) NSString *placeholderImage;
    6. ->
    7. @property (nonatomic, copy ) NSString *placeholderImageName;
    8. // All methods' name.
    9. timerInterval -> timeInterval
    10. placeholderImage -> placeholderImageName

V 1.2.5

  • Update README and some documents.

V 1.2.2

  • Update CocoaPods source URL.

V 1.2.0

  • You could custom the images should scrolling now, thx ac1dpax. For example:

    1. LCBannerView *bannerView = [[LCBannerView alloc] initWithFrame:CGRectMake(0, 20.0f, [UIScreen mainScreen].bounds.size.width, 200.0f)
    2. delegate:self
    3. imageName:@"banner"
    4. count:3
    5. timerInterval:3.0f
    6. currentPageIndicatorTintColor:[UIColor orangeColor]
    7. pageIndicatorTintColor:[UIColor whiteColor]];
    8. bannerView.pageDistance = 20.0f;
    9. bannerView.notScrolling = YES; // THIS LINE ⬅️
    10. bannerView;

V 1.1.0

  • You could custom page control bottom distance now. For example:

    1. // ...
    2. bannerView.pageDistance = 20.0f;

V 1.0.0

  • Initial commit.

Thanks

Support

License

MIT License