廣告圖的添加
問題描述:在啟動圖上添加不固定文字(網(wǎng)絡(luò)請求獲取的)般眉,或者廣告圖闹炉。
-
直接上一幀未?? oh yeah 版的效果圖吧!
解決辦法
<span id = "No.1">1. 自己建立一個AdvertisementViewController蟀苛,在AdvertisementViewController
里實(shí)現(xiàn)自己想要效果袋马,例如添加背景圖片 && logo && 展示文字的Label等非凌,viewdidload中調(diào)用adStart代碼如下:
- (void)adStart {
// 背景圖片
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
imageView.image = [UIImage imageNamed:@"launchpage_BackgroundImage"];
[self.view addSubview:imageView];
// 添加Logo
UIImage *logoIm = [UIImage imageNamed:@"launchpage_logo"];
CGFloat logoImWidth = logoIm.size.width;
CGFloat logImHeight = logoIm.size.height;
UIImageView *logoIV = [[UIImageView alloc] initWithFrame:CGRectMake((FrameW - logoImWidth)/2, FrameH - 84/2*WidthScale375 - logImHeight, logoImWidth, logImHeight)];
logoIV.image = logoIm;
[self.view addSubview:logoIV];
// 添加label
UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(5, FrameH - 15 - 40/2*WidthScale375, FrameW - 10, 15)];
lab.text = @"要展示的文字";
lab.textAlignment = NSTextAlignmentCenter;
[self.view addSubview:lab];
// 初始化定時器
_timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(adChangeNextViewController) userInfo:nil repeats:NO];
}
/** 定時展示完頁面后觸發(fā)方法 */
- (void)adChangeNextViewController {
[((AppDelegate *)([UIApplication sharedApplication].delegate)) showNextViewController];
}
2. 修改appDelegate
(1) appDelegate.h中暴露方法
/** 模擬啟動頁回來調(diào)用的方法 */
- (void)showNextViewController;
(2)appDelegate.m 在didFinishLaunchingWithOptions
方法中進(jìn)行相關(guān)更改
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// 模擬啟動頁
AdvertisementViewController *StartFigure = [[AdvertisementViewController alloc] init];
self.window.rootViewController = StartFigure;
[self.window makeKeyAndVisible];
return YES;
}
/** 模擬啟動頁回來調(diào)用的方法 */
- (void)showNextViewController {
// 模擬啟動圖結(jié)束了,跳這里瀑焦,這里面正常處理腌且,例如:改走引導(dǎo)頁,或者TabBarController或者登錄頁面等等榛瓮,自己決定啦铺董。。禀晓。
self.window.rootViewController= 引導(dǎo)頁/TabBarController/登錄頁面;
}