廣告界面搭建/屏幕適配

AppDelegate.mapp

#import "AppDelegate.h"
#import "XMGAdViewController.h"
@interface AppDelegate ()

@end

@implementation AppDelegate

// 程序啓動的時候就會調用
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    // 1.建立窗口
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    // 2.設置窗口根控制器
    XMGAdViewController *adVc = [[XMGAdViewController alloc] init];
    // init ->  initWithNibName 1.首先判斷有沒有指定nibName 2.判斷下有沒有跟類名同名xib
    self.window.rootViewController = adVc;
    
    // 3.顯示窗口 1.成爲UIApplication主窗口 2.
    [self.window makeKeyAndVisible];
    
    return YES;
}

XMGAdViewController.miphone

import "XMGAdViewController.h"


@interface XMGAdViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *launchImageView;
@property (weak, nonatomic) IBOutlet UIView *adContainView;

@end

@implementation XMGAdViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    // 設置啓動圖片
    [self setupLaunchImage];
    
    // 加載廣告數據
   
}

// 設置啓動圖片
- (void)setupLaunchImage
{
    // 6p:LaunchImage-800-Portrait-736h@3x.png
    // 6:LaunchImage-800-667h@2x.png
    // 5:LaunchImage-568h@2x.png
    // 4s:LaunchImage@2x.png
    if (iphone6P) { // 6p
        self.launchImageView.image = [UIImage imageNamed:@"LaunchImage-800-Portrait-736h@3x"];
    } else if (iphone6) { // 6
        self.launchImageView.image = [UIImage imageNamed:@"LaunchImage-800-667h"];
    } else if (iphone5) { // 5
        self.launchImageView.image = [UIImage imageNamed:@"LaunchImage-568h"];
        
    } else if (iphone4) { // 4
        
        self.launchImageView.image = [UIImage imageNamed:@"LaunchImage-700"];
    }
    
    
    
}
/***********屏幕適配*************/
#define XMGScreenW [UIScreen mainScreen].bounds.size.width
#define XMGScreenH [UIScreen mainScreen].bounds.size.height
#define iphone6P (XMGScreenH == 736)
#define iphone6 (XMGScreenH == 667)
#define iphone5 (XMGScreenH == 568)
#define iphone4 (XMGScreenH == 480)
/***********屏幕適配*************/
相關文章
相關標籤/搜索