推荐位View集成

目前推荐位支持

  • 单行4列
  • 两行4列
  • 三行4列 三种类型

如下图所示:

单/两行推荐 三行推荐

代码样例

- (void)setupAdsViews {
    CGFloat screenWidth = [[UIScreen mainScreen] bounds].size.width;

    // 单行推荐位
    UIView *oneRowTitleBar = [[UIView alloc] initWithFrame:(CGRect){CGPointMake(0, 64), CGSizeMake(screenWidth, 26)}];
    oneRowTitleBar.backgroundColor = [UIColor colorWithHexString:@"#DDDDDD"];
    [self.view addSubview:oneRowTitleBar];
    
    UILabel *oneRowTitle = [[UILabel alloc] initWithFrame:(CGRect){CGPointMake(8, 0), oneRowTitleBar.frame.size}];
    oneRowTitle.textColor = [UIColor colorWithHexString:@"#999999"];
    oneRowTitle.font = [UIFont systemFontOfSize:14];
    oneRowTitle.text = @"单行推荐位";
    [oneRowTitleBar addSubview:oneRowTitle];
    
    WXAdsView *adsView = [[WXAdsView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(oneRowTitleBar.frame), screenWidth, 76)];
    adsView.backgroundColor = [UIColor whiteColor];
    adsView.sourceViewController = self;
    [adsView setupOneRow];
    [self.view addSubview:adsView];
    
    
    // 两行推荐位
    UIView *twoRowTitleBar = [[UIView alloc] initWithFrame:(CGRect){CGPointMake(0, CGRectGetMaxY(adsView.frame)), CGSizeMake(screenWidth, 26)}];
    twoRowTitleBar.backgroundColor = [UIColor colorWithHexString:@"#DDDDDD"];
    [self.view addSubview:twoRowTitleBar];

    UILabel *twoRowTitle = [[UILabel alloc] initWithFrame:(CGRect){CGPointMake(8, 0), oneRowTitleBar.frame.size}];
    twoRowTitle.textColor = [UIColor colorWithHexString:@"#999999"];
    twoRowTitle.font = [UIFont systemFontOfSize:14];
    twoRowTitle.text = @"两行推荐位";
    [twoRowTitleBar addSubview:twoRowTitle];
    
    WXAdsView *twoAdsView = [[WXAdsView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(twoRowTitleBar.frame), screenWidth, 144)];
    twoAdsView.backgroundColor = [UIColor whiteColor];
    twoAdsView.sourceViewController = self;
    [twoAdsView setupTwoRow];
    [self.view addSubview:twoAdsView];
    
    
    // 三行推荐位
    UIView *threeRowTitleBar = [[UIView alloc] initWithFrame:(CGRect){CGPointMake(0, CGRectGetMaxY(twoAdsView.frame)), CGSizeMake(screenWidth, 26)}];
    threeRowTitleBar.backgroundColor = [UIColor colorWithHexString:@"#DDDDDD"];
    [self.view addSubview:threeRowTitleBar];

    UILabel *threeRowTitle = [[UILabel alloc] initWithFrame:(CGRect){CGPointMake(10, 0), oneRowTitleBar.frame.size}];
    threeRowTitle.textColor = [UIColor colorWithHexString:@"#999999"];
    threeRowTitle.font = [UIFont systemFontOfSize:14];
    threeRowTitle.text = @"三行推荐位";
    [threeRowTitleBar addSubview:threeRowTitle];

    WXAdsView *threeAdsView = [[WXAdsView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(threeRowTitleBar.frame), screenWidth, 212)];
    threeAdsView.backgroundColor = [UIColor whiteColor];
    threeAdsView.sourceViewController = self;
    [threeAdsView setupThreeRow];
    [self.view addSubview:threeAdsView];
}