启动页广告

#define IOS8_OR_LATER	( [[[UIDevice currentDevice] systemVersion] compare:@"8.0"] != NSOrderedAscending )
#define IOS7_OR_LATER	( [[[UIDevice currentDevice] systemVersion] compare:@"7.0"] != NSOrderedAscending )
#define IOS6_OR_LATER	( [[[UIDevice currentDevice] systemVersion] compare:@"6.0"] != NSOrderedAscending )
#define IOS5_OR_LATER	( [[[UIDevice currentDevice] systemVersion] compare:@"5.0"] != NSOrderedAscending )
#define IOS4_OR_LATER	( [[[UIDevice currentDevice] systemVersion] compare:@"4.0"] != NSOrderedAscending )
#define IOS3_OR_LATER	( [[[UIDevice currentDevice] systemVersion] compare:@"3.0"] != NSOrderedAscending )

#define IS_IPAD         ((UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad))
#define IS_IPADz         ([(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad) intValue])

#define IS_IPHONE_5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
#define IS_IPHONE_6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)
//iphone6_p  放大模式下的 currentMode反馈尺寸 (1125, 2001)
#define IS_IPHONE_6p (([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)||([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2001), [[UIScreen mainScreen] currentMode].size) : NO))
//#define IS_IPHONE_4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
#define WIDTH_FIT ([[UIScreen mainScreen] bounds].size.width/320)
#define HEIGHT_FIT (([[UIScreen mainScreen] bounds].size.height-64)/504)
#define IS_IPHONE_4 ([UIScreen mainScreen].bounds.size.height == 480)

#import "ViewController.h"
#import "WebViewController.h"
@interface ViewController ()
{
    UIButton *welImageBtn;//广告Button
    UIButton *welBackgroundBtn;//满屏启动页Button
}
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor grayColor];
    self.navigationController.navigationBarHidden = YES;
    self.title = @"主页";
    
    
    welImageBtn = [[UIButton alloc]initWithFrame:self.view.frame];
    welBackgroundBtn = [[UIButton alloc]initWithFrame:self.view.frame];
    
    if (!IS_IPHONE_4){
      
        if (IS_IPHONE_5)
        {
            welImageBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height -88)];
          
        }
        if (IS_IPHONE_6)
        {
            welImageBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 104)];
            
        }
        if (IS_IPHONE_6p)
        {
            welImageBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height -115)];
            
        }
        
        
        
    }
    welBackgroundBtn.backgroundColor = [UIColor greenColor];
    
    [self.view addSubview:welBackgroundBtn];
    [welBackgroundBtn addSubview:welImageBtn];
    
    [welImageBtn addTarget:self action:@selector(WelAdViewPressed) forControlEvents:UIControlEventTouchUpInside];
    [welImageBtn setImage:[UIImage imageNamed:@"human"] forState:UIControlStateNormal];
    [welImageBtn setImage:[UIImage imageNamed:@"human"] forState:UIControlStateHighlighted];
    //这里顺便提下直接提取 Xcode Images.xcassets的启动页图片 image = [UIImage imageNamed:@"LaunchImage-700-568h"];

    if (!IS_IPHONE_4){
        [self.view bringSubviewToFront:welImageBtn];
    }
    [self.view bringSubviewToFront:welBackgroundBtn];
    
   
    
    [NSTimer scheduledTimerWithTimeInterval:1.8 target:self selector:@selector(removeWelAD) userInfo:nil repeats:NO];
//    定时器停留的时间,点击跳转才能触发 。动画持续效果时间设置太长,点击无效,用户体验就很差了
}


-(void)removeWelAD
{
    [UIView animateWithDuration:1.0 animations:^{
        welImageBtn.alpha = 0.0;
        welBackgroundBtn.alpha = 0.0;
    } completion:^(BOOL finished) {
        [welImageBtn removeFromSuperview];
        [welBackgroundBtn removeFromSuperview];
        [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
    }];

}

-(void)WelAdViewPressed
{
    
    WebViewController *webView= [[WebViewController alloc]init];
    [self.navigationController pushViewController:webView animated:YES];
    NSLog(@"点击点击");
    
}

//刚开始做需求的时候用得UIImageView加手势做得触发 ,因为登陆界面总会弹出键盘,后来直接换成满屏的Button直接解决

启动页广告

启动页广告

启动页广告

启动页广告


你可能感兴趣的:(启动页广告)