fix
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#import "GiGaStartAdView.h"
|
||||
#import "GiGaFileNanager.h"
|
||||
#import "UIImageView+WebCache.h"
|
||||
#import "GiGaHelper.h"
|
||||
|
||||
@interface GiGaStartAdView()
|
||||
|
||||
@@ -17,6 +18,7 @@
|
||||
@property (nonatomic,assign) int count;
|
||||
|
||||
@end
|
||||
|
||||
static int const showTime = 5;
|
||||
|
||||
@implementation GiGaStartAdView
|
||||
@@ -40,50 +42,124 @@ static int const showTime = 5;
|
||||
}
|
||||
-(void)initUIWithFrame:(CGRect)frame{
|
||||
|
||||
self.backgroundColor = [UIColor whiteColor];
|
||||
self.backgroundColor = GIGARGB(131, 10,10, 1);
|
||||
_adView = [[UIImageView alloc] initWithFrame:frame];
|
||||
_adView.userInteractionEnabled = YES;
|
||||
_adView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
_adView.clipsToBounds = YES;
|
||||
//广告点击手势
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoAd)];
|
||||
[_adView addGestureRecognizer:tap];
|
||||
CGFloat btnW = 60;
|
||||
CGFloat btnH = 30;
|
||||
_countBtn = [[UIButton alloc] initWithFrame:CGRectMake(KMainW - btnW - 24, btnH + 10, btnW, btnH)];
|
||||
// UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoAd)];
|
||||
// [_adView addGestureRecognizer:tap];
|
||||
CGFloat btnW = 80;
|
||||
CGFloat btnH = 26;
|
||||
_countBtn = [[UIButton alloc] initWithFrame:CGRectMake(KMainW - btnW - 24,PhoneX_STATUBAR_H + 10, btnW, btnH)];
|
||||
|
||||
[_countBtn addTarget:self action:@selector(removeAdView) forControlEvents:UIControlEventTouchUpInside];
|
||||
[_countBtn setTitle:[NSString stringWithFormat:@"跳过%d",showTime] forState:UIControlStateNormal];
|
||||
_countBtn.titleLabel.font = [UIFont systemFontOfSize:15];
|
||||
[_countBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
||||
_countBtn.backgroundColor = GIGARGB(38, 38, 38, 0.6) ;
|
||||
// [_countBtn setTitle:[NSString stringWithFormat:@"跳过%d",showTime] forState:UIControlStateNormal];
|
||||
[_countBtn setTitle:GIGALocalComm(@"masktime_adview_passadtitle") forState:UIControlStateNormal];
|
||||
|
||||
_countBtn.titleLabel.font = [UIFont fontWithName:GIGA_FONTBOLD size:14];
|
||||
|
||||
[_countBtn setTitleColor:GIGARGB(144, 25, 31, 1) forState:UIControlStateNormal];
|
||||
_countBtn.backgroundColor = GIGARGB(235,234,234,1) ;
|
||||
_countBtn.layer.masksToBounds = YES;
|
||||
_countBtn.layer.cornerRadius = 4;
|
||||
_countBtn.layer.cornerRadius = _countBtn.frame.size.height / 2 ;
|
||||
[self addSubview:_adView];
|
||||
[self addSubview:_countBtn];
|
||||
|
||||
UIImageView *imageViewlogo = [[UIImageView alloc] init];
|
||||
imageViewlogo.image = [UIImage imageNamed:@"bg_logo"];
|
||||
|
||||
|
||||
UIImageView *imageView27Mask = [[UIImageView alloc] init];
|
||||
imageView27Mask.image = [UIImage imageNamed:@"bg_name"];
|
||||
imageView27Mask.contentMode = UIViewContentModeScaleAspectFit;
|
||||
|
||||
|
||||
UILabel *detailLabel = [[UILabel alloc] init];
|
||||
detailLabel.attributedText = [GiGaHelper stringWithText:GIGALocalComm(@"masktime_adview_desc") textColor:[UIColor whiteColor] textFont:GIGA_TEXTFONTBOLD(14) leterSpace:2];
|
||||
|
||||
UIButton *moreinfoBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
// [moreinfoBtn setImage:[UIImage imageNamed:@"btn_more"] forState:UIControlStateNormal];
|
||||
[moreinfoBtn setBackgroundImage:[UIImage imageNamed:@"btn_more"] forState:UIControlStateNormal];
|
||||
[moreinfoBtn addTarget:self action:@selector(gotoAd:) forControlEvents:UIControlEventTouchUpInside];
|
||||
NSMutableAttributedString *title = [[NSMutableAttributedString alloc] initWithString:@"了解更多" attributes:@{NSFontAttributeName:[UIFont fontWithName:GIGA_FONTNAME size:18],NSForegroundColorAttributeName:[UIColor whiteColor]}];
|
||||
[moreinfoBtn setAttributedTitle:title forState:UIControlStateNormal];
|
||||
|
||||
UILabel *year = [[UILabel alloc] init];
|
||||
year.textColor = [UIColor whiteColor];
|
||||
year.font = GIGA_TEXTFONTBOLD(10);
|
||||
year.text = @"2018";
|
||||
|
||||
[self addSubview:imageViewlogo];
|
||||
[self addSubview:imageView27Mask];
|
||||
[self addSubview:detailLabel];
|
||||
[self addSubview:moreinfoBtn];
|
||||
[self addSubview:year];
|
||||
[imageViewlogo mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.mas_top).offset(131);
|
||||
make.height.and.width.mas_equalTo(95);
|
||||
make.centerX.mas_equalTo(self.mas_centerX);
|
||||
}];
|
||||
[imageView27Mask mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.mas_top).offset(271);
|
||||
make.width.mas_equalTo(120);
|
||||
make.height.mas_equalTo(70);
|
||||
make.centerX.mas_equalTo(self.mas_centerX);
|
||||
|
||||
}];
|
||||
[detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.mas_top).offset(362);
|
||||
make.width.mas_equalTo(180);
|
||||
make.height.mas_equalTo(21);
|
||||
make.centerX.mas_equalTo(self.mas_centerX);
|
||||
|
||||
}];
|
||||
|
||||
[moreinfoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.mas_top).offset(478);
|
||||
make.width.mas_equalTo(135);
|
||||
make.height.mas_equalTo(35);
|
||||
make.centerX.mas_equalTo(self.mas_centerX);
|
||||
}];
|
||||
|
||||
[year mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(self.mas_bottom).offset(-(10 + PhoneX_BottomMargin));
|
||||
|
||||
make.width.mas_equalTo(31);
|
||||
make.height.mas_equalTo(14);
|
||||
make.left.mas_equalTo(20);
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
-(void)removeAdView{
|
||||
|
||||
[self.countTimer invalidate];
|
||||
self.countTimer = nil;
|
||||
[UIView animateWithDuration:0.3f animations:^{
|
||||
self.transform = CGAffineTransformMakeScale(1, 1);
|
||||
[UIView animateWithDuration:0.6f delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
|
||||
self.transform = CGAffineTransformMakeScale(1.4, 1.4);
|
||||
self.alpha = 0.f;
|
||||
} completion:^(BOOL finished) {
|
||||
[self removeFromSuperview];
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
-(void)gotoAd{
|
||||
[self removeAdView];
|
||||
-(void)gotoAd:(UIButton *)btn{
|
||||
|
||||
btn.userInteractionEnabled = NO;
|
||||
NC_POST_NAME_OBJECT(APP_PUSHTO_DETAILVIEW, nil);
|
||||
|
||||
[NSTimer scheduledTimerWithTimeInterval:0.6 target:self selector:@selector(removeAdView) userInfo:nil repeats:NO];
|
||||
//[self removeAdView];
|
||||
}
|
||||
|
||||
-(void)countDown{
|
||||
|
||||
_count --;
|
||||
[_countBtn setTitle:[NSString stringWithFormat:@"跳过%d",_count] forState:UIControlStateNormal];
|
||||
//[_countBtn setTitle:[NSString stringWithFormat:@"跳过%d",_count] forState:UIControlStateNormal];
|
||||
if (_count == 0) {
|
||||
[self removeAdView];
|
||||
}
|
||||
@@ -92,7 +168,7 @@ static int const showTime = 5;
|
||||
|
||||
-(void)show{
|
||||
|
||||
[self loadImage];
|
||||
//[self loadImage];
|
||||
UIWindow *window = [UIApplication sharedApplication].keyWindow;
|
||||
[window addSubview:self];
|
||||
//[self startTimer];
|
||||
@@ -135,7 +211,7 @@ static int const showTime = 5;
|
||||
|
||||
}else{ dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
[weakSelf.countBtn setTitle:[NSString stringWithFormat:@"跳过%d",timeout] forState:UIControlStateNormal];
|
||||
//[weakSelf.countBtn setTitle:[NSString stringWithFormat:@"跳过%d",timeout] forState:UIControlStateNormal];
|
||||
|
||||
});
|
||||
timeout--;
|
||||
|
||||
Reference in New Issue
Block a user