π₯A very popular and highly customized banner view! And, infinite loop!
In me the tiger sniffs the rose.
εΏζηθοΌη»ε
θ·θγ
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
propertie.
If you feel good, please give me a star, thank you very much! βοΈ
LCBannerView is available on CocoaPods. Just add the following to your project Podfile:
pod "LCBannerView" # Podfile
Just drag the LCBannerView folder into your project.
- 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
placeholderImage:nil
timerInterval:2.0f
currentPageIndicatorTintColor:[UIColor redColor]
pageIndicatorTintColor:[UIColor whiteColor]];
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
timerInterval:3.0f
currentPageIndicatorTintColor:[UIColor orangeColor]
pageIndicatorTintColor:[UIColor whiteColor]];
bannerView;
})];
- Delegate (
@optional
):
- (void)bannerView:(LCBannerView *)bannerView didClickedImageIndex:(NSInteger)index;
- For example:
- (void)bannerView:(LCBannerView *)bannerView didClickedImageIndex:(NSInteger)index {
NSLog(@"you clicked image in %@ at index: %ld", bannerView, (long)index);
}
// logs
2015-11-30 17:36:20.611 LCBannerViewDemo[6075:456257] you clicked image in <LCBannerView: 0x7fc98b751ff0; frame = (0 300; 375 200); layer = <CALayer: 0x7fc98b7521b0>> at index: 1
2015-11-30 17:36:21.292 LCBannerViewDemo[6075:456257] you clicked image in <LCBannerView: 0x7fc98b433190; frame = (0 20; 375 200); layer = <CALayer: 0x7fc98b42ce20>> at index: 1
2015-11-30 17:36:21.801 LCBannerViewDemo[6075:456257] you clicked image in <LCBannerView: 0x7fc98b751ff0; frame = (0 300; 375 200); layer = <CALayer: 0x7fc98b7521b0>> at index: 2
- Custom parameters (in
LCBannerView.m
):
// pageControl to the bottom of the distance
static CGFloat LCPageDistance = 10.0f;
- If you have any questions, please commit a issure! Thx!
- Email: [email protected] & [email protected]
- Blog: http://LeoDev.me & http://www.leodong.com