You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
3.0 KiB
85 lines
3.0 KiB
// |
|
// WXYZ_ADPangolinView.m |
|
// WXReader |
|
// |
|
// Created by Andrew on 2019/7/25. |
|
// Copyright © 2019 Andrew. All rights reserved. |
|
// |
|
|
|
#import "WXYZ_ADPangolinView.h" |
|
#import "WXYZ_ADPangolinVideo.h" |
|
#import "TFReaderSettingHelper.h" |
|
#import "AppDelegate.h" |
|
#import "UIView+LayoutCallback.h" |
|
|
|
@interface WXYZ_ADPangolinView () |
|
|
|
@property (nonatomic, weak) UILabel *titleLabel; |
|
@property (nonatomic, weak) UILabel *subtitle; |
|
/// 高度比例 |
|
@property (nonatomic, assign) CGFloat heightScale; |
|
|
|
@end |
|
|
|
@implementation WXYZ_ADPangolinView |
|
|
|
- (instancetype)initWithFrame:(CGRect)frame advertisementType:(TFAdvertisementType)type advertisementPosition:(TFAdvertisementPosition)position |
|
{ |
|
if (self = [super initWithFrame:frame advertisementType:type advertisementPosition:position]) { |
|
[self createSubviews]; |
|
} |
|
return self; |
|
} |
|
|
|
- (void)createSubviews { |
|
self.backgroundColor = [UIColor clearColor]; |
|
|
|
if (self.position == TFAdvertisementPositionEnd && self.type == TFAdvertisementTypeNovel) { |
|
UILabel *subtitle = [[UILabel alloc] init]; |
|
self.subtitle = subtitle; |
|
subtitle.backgroundColor = [UIColor clearColor]; |
|
UIColor *textColor = [TFReaderSettingHelper sharedManager].getReaderTextColor; |
|
subtitle.textColor = textColor; |
|
subtitle.font = kFont14; |
|
AppDelegate *delegate = (AppDelegate *)kRCodeSync([UIApplication sharedApplication].delegate); |
|
subtitle.text = [NSString stringWithFormat:@"%@%@", delegate.checkSettingModel.ad_status_setting.video_ad_text ?: @"", @">"]; |
|
[self addSubview:subtitle]; |
|
subtitle.frameBlock = ^(UIView * _Nonnull view) { |
|
[view addBorderLineWithBorderWidth:1.0 borderColor:textColor cornerRadius:0.0 borderType:UIBorderSideTypeBottom]; |
|
}; |
|
subtitle.userInteractionEnabled = YES; |
|
[subtitle addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(watchVideo)]]; |
|
|
|
UILabel *titleLabel = [[UILabel alloc] init]; |
|
self.titleLabel = titleLabel; |
|
titleLabel.backgroundColor = [UIColor clearColor]; |
|
titleLabel.text = TFLocalizedString(@"点击/滑动可继续阅读"); |
|
textColor = [textColor colorWithAlphaComponent:0.4]; |
|
titleLabel.textColor = textColor; |
|
titleLabel.textAlignment = NSTextAlignmentCenter; |
|
titleLabel.font = kFont17; |
|
[self addSubview:titleLabel]; |
|
} |
|
} |
|
|
|
- (void)setAdvertModel:(TFAdvertModel *)advertModel |
|
{ |
|
[super setAdvertModel:advertModel]; |
|
|
|
self.heightScale = 1.0 / 1.2; |
|
if (advertModel.ad_width > 0 && advertModel.ad_height > 0) { |
|
self.heightScale = (CGFloat)advertModel.ad_height / advertModel.ad_width; |
|
} |
|
if (self.position == TFAdvertisementPositionEnd) { |
|
self.heightScale = 1.0 / 1.2; |
|
} |
|
} |
|
/// 观看激励视频 |
|
- (void)watchVideo |
|
{ |
|
WXYZ_ADPangolinVideo *video = [[WXYZ_ADPangolinVideo alloc] initWithFrame:CGRectZero advertisementType:self.type advertisementPosition:self.position]; |
|
|
|
// [video show]; |
|
} |
|
|
|
@end
|
|
|