if (imgUrl) {
XTWeakSelf;
[self.aDImgView sd_setImageWithURL:[NSURL URLWithString:imgUrl] placeholderImage:self.imageLoading options:SDWebImageHighPriority completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
[weakSelf.aDImgView setImage:[weakSelf imageCompressForWidth:image targetWidth:mainWidth]];
weakSelf.aDImgView.frame = CGRectMake(0, 0, mainWidth, mainHeight *0.8);
}];
}
CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
opacityAnimation.duration = .3;
opacityAnimation.fromValue = [NSNumber numberWithFloat:0.8];
opacityAnimation.toValue = [NSNumber numberWithFloat:0.3];
opacityAnimation.removedOnCompletion = YES;
opacityAnimation.fillMode = kCAFillModeForwards;
[self.aDImgView.layer addAnimation:opacityAnimation forKey:@"animateOpacity"];
//设置圆圈
- (void)setAnimationSkipWithAttribute:(UIColor *)strokeColor lineWidth:(NSInteger)lineWidth {
self.shapelayer = [CAShapeLayer layer];
UIBezierPath *BezierPath = [UIBezierPath bezierPathWithOvalInRect:self.skipBtn.bounds];
self.shapelayer.lineWidth = lineWidth;
self.shapelayer.strokeColor = [strokeColor?strokeColor:[UIColor whiteColor] CGColor];
self.shapelayer.fillColor = [UIColor clearColor].CGColor;
self.shapelayer.path = BezierPath.CGPath;
[self.skipBtn.layer addSublayer:self.shapelayer];
}
-(void)startAnimation{
CABasicAnimation *pathAnimaton = [CABasicAnimation animationWithKeyPath:@"strokeStart"];
pathAnimaton.duration = _adTime -0.6;
pathAnimaton.fromValue = @(0.0f);
pathAnimaton.toValue = @(1.0f);
[self.shapelayer addAnimation:pathAnimaton forKey:nil];
}
- (void)launchAdSetting{
if (self.window.rootViewController.view) {
self.rootVC = self.window.rootViewController;
self.imgAdView = [[LBLaunchImageAdView alloc]init];
self.window.rootViewController = self.imgAdView;
}
}
XTWeakSelf;
LaunchAdDataController *loadingAd =[LaunchAdDataController new];
[loadingAd queryloadingAdsuccess:^(ResultInfo * loadingAdModel) {
if (loadingAdModel ) {
[ self.imgAdVC addLBlaunchImageAdViewWithImgUrl: loadingAdModel.screenshotUrl];
self.imgAdView.clickBlock = ^(clickType type){
};
}elsel{
[weakSelf changeRootVC];
}
/**
*
此处 VC 已经是之前的主界面VC, 可以跳转推送
*
*/
- (void)changeRootVC{
self.imgAdVC = nil;
self.window.rootViewController = self.rootVC;
}
// 点击通知进入应用
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void (^)())completionHandler {
NSDictionary * userInfo = response.notification.request.content.userInfo;
if([response.notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
//处理远程推送内容
[self changeRootVC];
[self notification:userInfo sender:@"程序未打开"];
[MiPushSDK handleReceiveRemoteNotification:userInfo];
}
completionHandler(UNNotificationPresentationOptionBadge + UNNotificationPresentationOptionSound);
}