[iOS]定制性强的广告轮播图--SCAdView

 

pod 'SCAdView'

 

    SCAdView *adView = [[SCAdView alloc] initWithBuilder:^(SCAdViewBuilder *builder) {
        builder.adArray = arrayFromService;
        builder.viewFrame = (CGRect){0,100,self.view.bounds.size.width,self.view.bounds.size.width/2.f};
        builder.adItemSize = (CGSize){self.view.bounds.size.width/2.5f,self.view.bounds.size.width/4.f};
        builder.minimumLineSpacing = 0;
        builder.secondaryItemMinAlpha = 0.6;
        builder.threeDimensionalScale = 1.45;
        builder.itemCellNibName = @"SCAdDemoCollectionViewCell";
    }];

About SCAdViewBuilder

Please read SCAdViewBuilder's interface in SCAdView.hfile.

Effects

Horizontal scrolling

Vertical scrolling

SCAdView

前言

如果我的代码能帮助到你哪怕是一点点,请点一下star。谢谢你的支持,你的star是我的动力。

介绍

SCAdView是一个支持2D平面效果和3D缩放效果 , 可定制上下左右方向滚动 , 有限/无限循环 轮播的轮播控件

安装

手动安装

下载源代码并解压,将目录下SCAdView文件夹添加到你的项目中

CocoaPods

创建或在你的 podfile中添加:

pod 'SCAdView'

然后到终端cd到目录下执行 pod install

用法

在使用的时候,我们应该通过一个SCAdViewBuilder对象来构造出SCAdView,而我们可以通过在构造方法中修改buidler中的属性,来定制一个我们想要的 SCAdView
eg.

 

#pragma mark -水平模式
/**
 *  @brief 水平显示
 */
-(void)showAdHorizontally{
    SCAdView *adView = [[SCAdView alloc] initWithBuilder:^(SCAdViewBuilder *builder) {
        builder.viewFrame = (CGRect){0,0,Width,Height-SafeAreaTopHeight-Width*0.2};
        builder.adItemSize = (CGSize){Width/1.8,Height/2};
        builder.minimumLineSpacing = Width*0.1;
        builder.secondaryItemMinAlpha = 1.0;
        builder.threeDimensionalScale = 1.3;
        builder.itemCellNibName = @"SCAdDemoCollectionViewCell";
        builder.infiniteCycle =5.0f;
    }];
    adView.backgroundColor = [UIColor clearColor];
    adView.delegate = self;
    _adView = adView;
    [self.view addSubview:adView];
    UIBlurEffect* effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
    UIVisualEffectView* effectView = [[UIVisualEffectView alloc] initWithEffect:effect];
    effectView.frame = CGRectMake(0, 0, Width, Height);
    [_bottomImgView addSubview:effectView];
}
#pragma mark -delegate
-(void)sc_didClickAd:(id)adModel{
    NSLog(@"sc_didClickAd-->%@",adModel);
    if ([adModel isKindOfClass:[HeroModel class]]) {
        NSLog(@"%@",((HeroModel*)adModel).imageName);
        if (_adView) {
            [_adView pause];
        }
        BaseWKWebviewVC * VC = [[BaseWKWebviewVC alloc]initWithUrl:[((HeroModel*)adModel).link_url HtmlToString]];
        PushVC(VC);
    }
}
-(void)sc_scrollToIndex:(NSInteger)index{
    NSLog(@"sc_scrollToIndex-->%ld",index);
    if (self.dataArray.count>index) {
        HeroModel*model = self.dataArray[index];
         [_bottomImgView SD_WebimageUrlStr:model.background_url placeholderImage:nil];
    }
}

 

 

SCAdViewBuilder 的详解

请到SCAdView.h文件查阅SCAdViewBuilder的 interface。

效果

https://www.jianshu.com/p/232a0b429f37

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值