1、Storyboard拖拽一个UIView到你要放轮播的位置,约束好大小(当然也可以用代码方式)
2、Storyboard中将这个UIView的类设置为WMAdPageView
3、连接IBOutlet到ViewController
4、设置_adPageView的image和其他。
#import "WMAdPageView.h"
_adPageView.dotPosition = WMAdPageDotRight;
[_adPageView setAdsWithImages:@[@"m1", @"m2", @"m3", @"m4", @"m5"]
block:^(NSInteger clickIndex){
NSLog(@"%ld", (long)clickIndex);
}];
pod 'WMADPageView', :git => 'https://github.com/emilyZhouwm/WMADPageView.git'
_adPageView.delegate = self;
[_adPageView setAdsWithImages:@[@"xxxurl", @"xxxurl", @"xxxurl", @"xxxurl"]
block:^(NSInteger clickIndex){
NSLog(@"%ld", (long)clickIndex);
}];
[_adPageView setBAutoRoll:YES];
#pragma mark - WMAdPageViewDelegate
- (void)setWebImage:(UIImageView *)imgView imgUrl:(NSString *)imgUrl
{
// 例如,使用SDWebImage
[imgView sd_setImageWithURL:[NSURL URLWithString:imgUrl] placeholderImage:[UIImage imageNamed:@"default"]];
}
图片版权:考满分网

