iOS 启动图片,之后的广告图片效果

news/2024/7/20 20:59:23 标签: iOS, app开屏广告, oc

iOS 应用添加开屏广告

在AppDelegate.h中的代码

ocessor" style="color:rgb(203,75,22)">#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UIImageView *adImageView;
@property (strong, nonatomic) UINavigationController *rootNavi;

@end
在AppDelegate.m中的代码

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]bounds]];
    // Override point for customization after application launch.
    AlertDemoViewController *vc = [[AlertDemoViewController alloc]init];

    UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:vc];

    if (isIOS7) {
        [navi.navigationBar setBarTintColor:[UIColor clearColor]];
    }else{
        [navi.navigationBar setTintColor:[UIColor clearColor]];
    }
    self.rootNavi = navi;

    //self.window.rootViewController = navi;

    self.adImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen]bounds].size.height)];
    [self.adImageView setImage:[UIImage imageNamed:@"tmplecture"]];
    [self.window addSubview:self.adImageView];
    [self performSelector:@selector(removeAdImageView) withObject:nilafterDelay:3];

    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}

- (void)removeAdImageView
{
    [UIView animateWithDuration:0.3f animations:^{
        self.adImageView.transform = CGAffineTransformMakeScale(0.5f,0.5f);
        self.adImageView.alpha = 0.f;
    } completion:^(BOOL finished) {
        [self.adImageView removeFromSuperview];
        self.window.rootViewController = self.rootNavi;
    }];
}


淡入淡出更换 rootViewController

- (void)restoreRootViewController:(UIViewController *)rootViewController
{
 typedef void (^Animation)(void);
 UIWindow* window = self.window;

 rootViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
 Animation animation = ^{
  BOOL oldState = [UIView areAnimationsEnabled];
  [UIView setAnimationsEnabled:NO];
  window.rootViewController = rootViewController;
  [UIView setAnimationsEnabled:oldState];
 };

 [UIView transitionWithView:window
       duration:0.5f
        options:UIViewAnimationOptionTransitionCrossDissolve
     animations:animation
     completion:nil];
}


文/Lonely__(简书作者)
原文链接:http://www.jianshu.com/p/6dc2713bf8d1
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。


http://www.niftyadmin.cn/n/652411.html

相关文章

UIView 中常见的方法总结

UIView 中常见的方法总结 addSubview: 添加一个子视图到接收者并让它在最上面显示出来。 - (void)addSubview:(UIView *)view 讨论 这方法同样设置了接收者为下一个视图响应对象。接收者保留视图。如果你使用removeFromSuperview方法用来把视图移除他的显示列表&#xff0c…

如何手工删除AD RMS SCP?

目前微软的最新的windows server 2012已经推出&#xff0c;在windows server 2012的域环境安装IRM时&#xff0c;我们发现SCP不能注册 成 功&#xff0c;原因就是之前windows server 2008的域环境下的AD RMS SCP没有清理掉。 在此环境中&#xff0c;需要手工删除AD RMS SCP。以…

iOS MKMapView 基础知识

property(nonatomic) MKMapType mapType //要显示地图的类型enum {MKMapTypeStandard, //标准地图&#xff0c;显示所有道路和路名MKMapTypeSatellite, //显示卫星视图。MKMapTypeHybrid //混合显示&#xff0c;将卫星视图展示在标准地图上};typedef NSUInteger MKMapType;prop…

使用组策略向域中计算机的组添加或删除成员

配置受限制的组 使用组策略中“受限制的组”可以控制组的成员或组所属的组。这样可以集中控制域中计算机或服务器的特定组的成员和特定组的所属的组。以下示例将会说明受限组的作用。 示例&#xff1a;配置受限制的组 李文斌域用户需要使用远程桌面管理公司服务器&#xff0c;为…

git 误删分支恢复方法 from csdner 傲雪星枫

版权声明&#xff1a;本文为博主原创文章&#xff0c;遵循 CC 4.0 BY-SA 版权协议&#xff0c;转载请附上原文出处链接和本声明。 本文链接&#xff1a;https://blog.csdn.net/fdipzone/article/details/50616386 在使用git的过程中&#xff0c;因为人为因素造成分支&#xff…

OC与JS交互

原生页面和H5的混合开发是我们必须熟悉的技能.以下是几种简单快速的上手方法。. 1.WebviewJavaScriptBridge的使用 WebviewJavaScriptBridge三方的桥接,使得混合开发变得比较容易,在此详述一下,使得你能够快速实现两种代码的交互. 1.首先下载WebviewJavaScriptBridge包拉进工…

Runloop 实现原理及应用

程序从启动开始&#xff0c;一直都是按照苹果封装好的代码运行着&#xff0c;暴露的一些属性和方法作为接口&#xff0c;是让我们在给定的方法里写代码实现自定义功能&#xff0c;做出各种各样的应用。这些方法的调用顺序最为关键&#xff0c;熟悉了程序运转和方法调用的顺序&a…

在字符串中附加格式化的字符串

var MyBuilder new StringBuilder("你的工资是&#xff1a;"); var MySalary 4120.24; MyBuilder.AppendFormat("{0:C}", MySalary); Response.Write(MyBuilder);//你的工资是&#xff1a;&#xffe5;4,120.24转载于:https://www.cnblogs.com/Yellowsho…