• Stars
    star
    159
  • Rank 235,916 (Top 5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 9 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

LCBannerView

Travis CocoaPods CocoaPods CocoaPods LeoDev

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

LCBannerView

In me the tiger sniffs the rose.

心有猛虎,细嗅蔷薇。

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:

pod "LCBannerView"  # Podfile

Non-CocoaPods Installation

Just drag the LCBannerView folder into your project.

Usage

  • Use by including the following import:

    #import "LCBannerView.h"
  • Demo code:

    // 1. From internet
    [scrollView addSubview:({
    
        LCBannerView *bannerView = [LCBannerView bannerViewWithFrame:CGRectMake(0, 300.0f, [UIScreen mainScreen].bounds.size.width, 200.0f)
                                                            delegate:self
                                                           imageURLs:URLs
                                                placeholderImageName:nil
                                                        timeInterval:2.0f
                                       currentPageIndicatorTintColor:[UIColor redColor]
                                              pageIndicatorTintColor:[UIColor whiteColor]];
        bannerView.pageDistance = 20.0f;
        bannerView;
    })];
    
    // 2. From local
    // If you using images from local, you should let images named: `[email protected]`, `[email protected]`...
    // Than, you just give me a image named: `banner`. 😜
    [scrollView addSubview:({
    
        LCBannerView *bannerView = [[LCBannerView alloc] initWithFrame:CGRectMake(0, 20.0f, [UIScreen mainScreen].bounds.size.width, 200.0f)
                                                              delegate:self
                                                             imageName:@"banner"
                                                                 count:3
                                                          timeInterval:3.0f
                                         currentPageIndicatorTintColor:[UIColor orangeColor]
                                                pageIndicatorTintColor:[UIColor whiteColor]];
        bannerView;
    })];
  • 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)

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

    For example:

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

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

    For example:

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

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

ChangeLog

V 2.1.1

  • Hide pageControl support:

    // Hide or show pageControl. Default is `NO`, show pageControl.
    @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:

    // Properties' name.
    @property (nonatomic, assign) CGFloat timerInterval;
    ->
    @property (nonatomic, assign) CGFloat timeInterval;
    
    @property (nonatomic, copy  ) NSString  *placeholderImage;
    ->
    @property (nonatomic, copy  ) NSString  *placeholderImageName;
    
    // All methods' name.
    timerInterval -> timeInterval
    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:

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

V 1.1.0

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

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

V 1.0.0

  • Initial commit.

Thanks

Support

  • If you have any question, just commit a issue :)

  • Mail: echo bGVvZGF4aWFAZ21haWwuY29tCg== | base64 -D or echo ZGV2dGlwQDE2My5jb20K | base64 -D

  • Blog: https://LeoDev.me

  • Donations:

    • PayPal:

      Donate

    • Alipay or Wechat Pay:

      Donate with Alipay or Wechat Pay

    Please note: donation does not imply any type of service contract.

License

MIT License

More Repositories

1

LCActionSheet

一款简约而不失强大的 ActionSheet,微博、微信和 QQ 都采用了极其类似的样式,完全支持 Swift。
Objective-C
821
star
2

LCTabBarController

A amazing and highly customized tabBarController! You could almost customize 100% properties with LCTabBarController!
Objective-C
385
star
3

LCNavigationController

除 UINavigationController 外最流行的 NavigationController!
Objective-C
226
star
4

LCDownloadManager

一个简单易用的下载助手。基于AFN,实现断点续传,采取Block方式回调下载进度、文件大小、下载是否完成等。
Objective-C
183
star
5

LCNewFeature

几行代码快速集成新特性界面!
Objective-C
108
star
6

LCProgressHUD

一个超简单的活动指示器。适配横屏。
Objective-C
102
star
7

XXWB

当初学习 iOS 开发时写的小小微博,高仿新浪微博首页!仅供学习哈!请阅读下方必读!!!!
Objective-C
59
star
8

LCCoolHUD

一款酷酷的 HUD。
Objective-C
28
star
9

ReusableProtocol

A helpful and pure Swift implemented library for registering and reusing cells or views in the table view and collection view.
Swift
27
star
10

LCPaintView

🖌 Paint view for iOS.
Objective-C
20
star
11

Xia

🌟 Naughty flexible alert view above the navigation bar.
Swift
19
star
12

LCBlur

Quick way to add blur effect ~
Objective-C
18
star
13

ShakeDemo

摇一摇Demo
Objective-C
17
star
14

ApplePayDemo

 Pay Demo with Swift.
Swift
17
star
15

LCLoadingHUD

彩虹加载指示器。
Objective-C
16
star
16

WeChat

基于XMPP模仿微信App进行IM(即时聊天)开发,并适配iPad、iOS7。(暂停开发,有空再讲……)
Objective-C
14
star
17

SearchBarDemo

Objective-C
13
star
18

LCTipView

An individuality tip view.
Objective-C
11
star
19

LCUtils

个人在开发中使用的工具类。
Objective-C
10
star
20

Grids

⚠️ UIStackView IS A BETTER SOLUTION. 🏁 Grids layout, making views equidistant. Base on SnapKit.
Swift
7
star
21

Da

🌟 Naughty flexible alert view. Like QQ's.
Swift
5
star
22

LCAlertView

Using UIAlertView with Block!
Objective-C
3
star
23

FMDBDemo

A demo for FMDB.
Objective-C
3
star
24

DaXia

🍰 Naughty flexible alert view :) Contains Da and Xia.
Ruby
3
star
25

WebVC

UIWebView + 自定义 Request 的 Header 中添加键值对 KeyValues
Objective-C
1
star
26

UIAlertViewDemo

How to implement the UIAlertView of the system?
Objective-C
1
star
27

FileShareDemo

Demo for share files with iTunes.
Swift
1
star
28

LEONetworkKit

LEONetworkKit is a part of LEOKit. Have fun!
Objective-C
1
star
29

XcodeConfigs

Inspiration from: https://github.com/johnil/xcode_configs
1
star
30

LCCalendarView

For LanMeng Tec.
Objective-C
1
star
31

LCWebViewController

一个带进度条、带工具条、可高度自定义的浏览器!
Objective-C
1
star