Giter VIP home page Giter VIP logo

lcbannerview's Introduction

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

lcbannerview's People

Contributors

damonhu avatar itofu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lcbannerview's Issues

Detect which image was pressed in tableview cell

Is it possible to detect which image was pressed in which cell of tableview?

I add LCBannerView as subview of cell view, and have array of photos loaded in lot of cells, how can I detect in which cell photo did pressed? many thanks!

[Question] Syntax problem?

What is the syntax of the code?

[self addSubview:({

        UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, scrollW, scrollH)];

        [self addSubviewToScrollView:scrollView];

        scrollView.delegate                       = self;
        scrollView.scrollsToTop                   = NO;
        scrollView.pagingEnabled                  = YES;
        scrollView.showsHorizontalScrollIndicator = NO;
        scrollView.contentOffset                  = CGPointMake(scrollW, 0);
        scrollView.contentSize                    = CGSizeMake((self.count + 2) * scrollW, 0);

        self.scrollView = scrollView;
    })];

C++ Lambda syntax? If remove the self.scrollView = scrollView; compiler to the error. The return value is not automatically speculated?

Adding in UITableViewCell

I’m adding LCBannerView in a UITableViewCell, it seems that it is adding this again and again as i’m seeing overlapped images after scrolling.

Any suggestions how can I fix this?

Implementing this library in Swift 3

hi,
can we implement this in swift?
I tried but could not get to load images from internet.

i added a UIView on storyboard and set its class to LCBannerView.

Then created outlet for the view as
@IBOutlet weak var lgAddBannerView: LCBannerView!

then on viewed load as below:

override func viewDidLoad() {
super.viewDidLoad()
self.lgAddBannerView.imageURLs = ["https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQUSaoTcU7EiRBKlB26__J_YhAXK5WUjffGO9lQZ5bHgJs5Boybzg",
"https://cdn.pixabay.com/photo/2016/05/04/15/52/cats-1371991_960_720.jpg", "http://image5.tuku.cn/wallpaper/Animal%20Wallpapers/5491_2560x1600.jpg"]
self.lgAddBannerView.currentPageIndicatorTintColor = UIColor.red
self.lgAddBannerView.pageIndicatorTintColor = UIColor.white
self.lgAddBannerView.pageDistance = 20
self.lgAddBannerView.frame = CGRect(x: 0, y:0, : width: screen width, height: 150)
}

But it dod not worked for me.
Is there any way to make it work with Swift 3?
Help would be appreciated.

Thanks

Scroll even if only one image

How to prevent scrolling if array have only one image? I load images from internet and sometimes there is only one image then I don't want to scroll it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.