LJBannerView 1.0.2

LJBannerView 1.0.2

lijian维护。



  • lijian

LJBannerView

  • 简单的图片轮播器,基于UIScrollView实现

example_1example_2

特点

  • 支持在Storyboard/xib中创建
  • 支持自动布局

安装

1 Pod安装

pod 'LJBannerView'  

此库已包含依赖库SDWebImage

2 手动安装

将项目文件中的LJBannerView .m/.h 拷贝到自己的项目中,并自行添加SDWebImage库
导入头文件

#import "LJBannerView.h"

使用

创建

  1. 通过框架创建
  LJBannerView *bannerView = [[LJBannerView alloc] initWithFrame:CGRectMake(0, 90, [UIScreen mainScreen].bounds.size.width, 220.0f)];
  [self.view addSubview:bannerView];
  [bannerView setImageURLArr:@[@"http://www.xdowns.com/attachment/android/images/1709/170912094146.jpg",@"http://img3.3lian.com/2013/s1/30/d/62.jpg",@"http://image2.suning.cn/uimg/shp/userItems/151712398561123589_3.jpg"]];
  1. 通过_masonry_创建
  LJBannerView *bannerView = [[LJBannerView alloc] init];
  [self.view addSubview:bannerView];
  [bannerView mas_makeConstraints:^(MASConstraintMaker *make) {
      make.top.equalTo(self.view).with.offset(100);
      make.left.equalTo(self.view).with.offset(0);
      make.right.equalTo(self.view).with.offset(0);
      make.height.mas_offset(@220);
  }];
  
  [bannerView setImageURLArr:@[@"http://www.xdowns.com/attachment/android/images/1709/170912094146.jpg",@"http://img3.3lian.com/2013/s1/30/d/62.jpg",@"http://image2.suning.cn/uimg/shp/userItems/151712398561123589_3.jpg"]];
  1. 通过_Xib_创建
    example_xib
#import "XibCreateViewController.h"
#import "LJBannerView.h"

@interface XibCreateViewController ()
@property (weak, nonatomic) IBOutlet LJBannerView *bannerView;
@end

@implementation XibCreateViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.bannerView setImageURLArr:@[@"http://www.xdowns.com/attachment/android/images/1709/170912094146.jpg",@"http://img3.3lian.com/2013/s1/30/d/62.jpg",@"http://image2.suning.cn/uimg/shp/userItems/151712398561123589_3.jpg"]];
}
@end

属性/方法

  1. 配置PageControl的颜色
@property (strong, nonatomic) UIColor *currentPageIndicatorTintColor;
@property (strong, nonatomic) UIColor *pageIndicatorTintColor;
  1. 设置本地图片
- (void)setLocalImageArr:(NSArray *)localImgArr;
  1. 设置网络图片
- (void)setImageURLArr:(NSArray *)imgURLArr;
  1. 代理获取点击下标
- (void)LJBannerViewDelegateClickForIndex:(NSInteger)index;