#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直接解決