iphone--启动界面的制作
2012-03-06 23:13
330 查看
第一种方式
在iphone的启动应用之前,系统会默认在Resources文件夹中的Default.png,为启动界面。
为了在iPad上使用上述的启动画面,你还需要在info.plist中加入
key: UISupportedInterfaceOrie
ntations。
同时,加入值
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight。
如果觉的启动界面时间比较短,也可以加入下面代码控制一下:
代码如下;
- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[NSThread sleepForTimeInterval:3];
returnYES;
}
加上动画
原理:
添加一张和Default.png一样的图片,对这个图片进行动画,从而实现Default动画的渐变消失的效果。 操作:
在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions中添加如下代码: // Make this interesting.
UIImageView *splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)]; splashView.image = [UIImage imageNamed:@"Default.png"];
[self.window addSubview:splashView]; [self.window bringSubviewToFront:splashView];
[UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:2.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView: self.window cache:YES]; [UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)]; splashView.alpha = 0.0;
splashView.frame = CGRectMake(-60, -85, 440, 635); [UIView commitAnimations];
就ok了
iphone项目的启动界面尺寸设为320x480,系统自带的,进行加载。
自定义的显示页面
[b]//PRPSplashScreenDelegate.h
@class PRPSplashScreen;
@protocol PRPSplashScreenDelegate<NSObject>
@optional
- (void)splashScreenDidAppear:(PRPSplashScreen*)splashScreen;
- (void)splashScreenWillDisappear:(PRPSplashScreen*)splashScreen;
- (void)splashScreenDidDisappear:(PRPSplashScreen*)splashScreen;
@end
//PRPSplashScreen.h
#import "PRPSplashScreenDelegate.h"
@interface PRPSplashScreen : UIViewController {}
@property (nonatomic, retain) UIImage*splashImage;
@property (nonatomic, assign) BOOLshowsStatusBarOnDismissal;
@property (nonatomic, assign) IBOutletid<PRPSplashScreenDelegate>delegate;
- (void)hide;
@end
//PRPSplashScreen.m
#import "PRPSplashScreen.h"
@implementation PRPSplashScreen
@synthesize splashImage;
@synthesize showsStatusBarOnDismissal;
@synthesize delegate;
- (void)dealloc {
[splashImagerelease], splashImage = nil;
[superdealloc];
}
- (void)viewDidUnload {
[superviewDidUnload];
self.splashImage = nil;
}
- (void)loadView {
UIImageView *iv= [[UIImageView alloc] initWithImage:self.splashImage];
iv.autoresizingMask = UIViewAutoresizingFlexibleWidth|
UIViewAutoresizingFlexibleHeight;
iv.contentMode= UIViewContentModeCenter;
self.view =iv;
[ivrelease];
}
- (UIImage *)splashImage {
if (splashImage== nil) {
self.splashImage = [UIImageimageNamed:@"Default.png"];
}
returnsplashImage;
}
- (void)hide {
if(self.showsStatusBarOnDismissal)
{
UIApplication *app =[UIApplication sharedApplication];
[app setStatusBarHidden:NOwithAnimation:UIStatusBarAnimationFade];
}
[selfdismissModalViewControllerAnimated:YES];
}
- (void)viewDidAppear:(BOOL)animated {
[superviewDidAppear:animated];
SELdidAppearSelector = @selector(splashScreenDidAppear:);
if([self.delegate respondsToSelector:didAppearSelector]) {
[self.delegatesplashScreenDidAppear:self];
}
[selfperformSelector:@selector(hide) withObject:nil afterDelay:0];
}
- (void)viewWillDisappear:(BOOL)animated {
[superviewWillDisappear:animated];
if([self.delegaterespondsToSelector:@selector(splashScreenWillDisappear:)]) {
[self.delegatesplashScreenWillDisappear:self];
}
}
- (void)viewDidDisappear:(BOOL)animated {
[superviewDidDisappear:animated];
if([self.delegaterespondsToSelector:@selector(splashScreenDidDisappear:)]) {
[self.delegatesplashScreenDidDisappear:self];
}
}
@end
//AppDelagate.h
#import "PRPSplashScreen.h"
@interface AppDelegate_iPhone : NSObject<UIApplicationDelegate,PRPSplashScreenDelegate> {}
@property (nonatomic, retain) IBOutlet UIWindow*window;
@property (nonatomic, retain) IBOutletUINavigationController *navController;
@property (nonatomic, retain) IBOutletPRPSplashScreen *splashScreen;
@end
//AppDelagate.m
#import "AppDelegate_iPhone.h"
#import "PRPSplashScreen.h"
@implementation AppDelegate_iPhone
@synthesize window;
@synthesize navController;
@synthesize splashScreen;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication*)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.windowaddSubview:self.navController.view];
self.splashScreen.showsStatusBarOnDismissal = YES;
self.splashScreen.modalTransitionStyle =UIModalTransitionStyleFlipHorizontal;
[self.navController presentModalViewController:splashScreenanimated:NO];
[self.windowmakeKeyAndVisible];
return YES;
}
- (void)splashScreenDidAppear:(PRPSplashScreen*)splashScreen {
NSLog(@"splashScreenDidAppear!");
}
- (void)splashScreenWillDisappear:(PRPSplashScreen*)splashScreen {
NSLog(@"splashScreenWillDisappear!");
}
- (void)splashScreenDidDisappear:(PRPSplashScreen*)splashScreen {
self.splashScreen = nil;
}
- (void)dealloc {
[windowrelease], window = nil;
[navControllerrelease], navController = nil;
[splashScreenrelease], splashScreen = nil;
[superdealloc];
}
[/b]
原文地址:http://www.cocoachina.com/bbs/read.php?tid=73570&page=1
在iphone的启动应用之前,系统会默认在Resources文件夹中的Default.png,为启动界面。
为了在iPad上使用上述的启动画面,你还需要在info.plist中加入
key: UISupportedInterfaceOrie
ntations。
同时,加入值
UIInterfaceOrientationPortrait
UIInterfaceOrientationPortraitUpsideDown
UIInterfaceOrientationLandscapeLeft
UIInterfaceOrientationLandscapeRight。
如果觉的启动界面时间比较短,也可以加入下面代码控制一下:
代码如下;
- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[NSThread sleepForTimeInterval:3];
returnYES;
}
加上动画
原理:
添加一张和Default.png一样的图片,对这个图片进行动画,从而实现Default动画的渐变消失的效果。 操作:
在- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions中添加如下代码: // Make this interesting.
UIImageView *splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0, 320, 480)]; splashView.image = [UIImage imageNamed:@"Default.png"];
[self.window addSubview:splashView]; [self.window bringSubviewToFront:splashView];
[UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:2.0];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView: self.window cache:YES]; [UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)]; splashView.alpha = 0.0;
splashView.frame = CGRectMake(-60, -85, 440, 635); [UIView commitAnimations];
就ok了
iphone项目的启动界面尺寸设为320x480,系统自带的,进行加载。
自定义的显示页面
[b]//PRPSplashScreenDelegate.h
@class PRPSplashScreen;
@protocol PRPSplashScreenDelegate<NSObject>
@optional
- (void)splashScreenDidAppear:(PRPSplashScreen*)splashScreen;
- (void)splashScreenWillDisappear:(PRPSplashScreen*)splashScreen;
- (void)splashScreenDidDisappear:(PRPSplashScreen*)splashScreen;
@end
//PRPSplashScreen.h
#import "PRPSplashScreenDelegate.h"
@interface PRPSplashScreen : UIViewController {}
@property (nonatomic, retain) UIImage*splashImage;
@property (nonatomic, assign) BOOLshowsStatusBarOnDismissal;
@property (nonatomic, assign) IBOutletid<PRPSplashScreenDelegate>delegate;
- (void)hide;
@end
//PRPSplashScreen.m
#import "PRPSplashScreen.h"
@implementation PRPSplashScreen
@synthesize splashImage;
@synthesize showsStatusBarOnDismissal;
@synthesize delegate;
- (void)dealloc {
[splashImagerelease], splashImage = nil;
[superdealloc];
}
- (void)viewDidUnload {
[superviewDidUnload];
self.splashImage = nil;
}
- (void)loadView {
UIImageView *iv= [[UIImageView alloc] initWithImage:self.splashImage];
iv.autoresizingMask = UIViewAutoresizingFlexibleWidth|
UIViewAutoresizingFlexibleHeight;
iv.contentMode= UIViewContentModeCenter;
self.view =iv;
[ivrelease];
}
- (UIImage *)splashImage {
if (splashImage== nil) {
self.splashImage = [UIImageimageNamed:@"Default.png"];
}
returnsplashImage;
}
- (void)hide {
if(self.showsStatusBarOnDismissal)
{
UIApplication *app =[UIApplication sharedApplication];
[app setStatusBarHidden:NOwithAnimation:UIStatusBarAnimationFade];
}
[selfdismissModalViewControllerAnimated:YES];
}
- (void)viewDidAppear:(BOOL)animated {
[superviewDidAppear:animated];
SELdidAppearSelector = @selector(splashScreenDidAppear:);
if([self.delegate respondsToSelector:didAppearSelector]) {
[self.delegatesplashScreenDidAppear:self];
}
[selfperformSelector:@selector(hide) withObject:nil afterDelay:0];
}
- (void)viewWillDisappear:(BOOL)animated {
[superviewWillDisappear:animated];
if([self.delegaterespondsToSelector:@selector(splashScreenWillDisappear:)]) {
[self.delegatesplashScreenWillDisappear:self];
}
}
- (void)viewDidDisappear:(BOOL)animated {
[superviewDidDisappear:animated];
if([self.delegaterespondsToSelector:@selector(splashScreenDidDisappear:)]) {
[self.delegatesplashScreenDidDisappear:self];
}
}
@end
//AppDelagate.h
#import "PRPSplashScreen.h"
@interface AppDelegate_iPhone : NSObject<UIApplicationDelegate,PRPSplashScreenDelegate> {}
@property (nonatomic, retain) IBOutlet UIWindow*window;
@property (nonatomic, retain) IBOutletUINavigationController *navController;
@property (nonatomic, retain) IBOutletPRPSplashScreen *splashScreen;
@end
//AppDelagate.m
#import "AppDelegate_iPhone.h"
#import "PRPSplashScreen.h"
@implementation AppDelegate_iPhone
@synthesize window;
@synthesize navController;
@synthesize splashScreen;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication*)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.windowaddSubview:self.navController.view];
self.splashScreen.showsStatusBarOnDismissal = YES;
self.splashScreen.modalTransitionStyle =UIModalTransitionStyleFlipHorizontal;
[self.navController presentModalViewController:splashScreenanimated:NO];
[self.windowmakeKeyAndVisible];
return YES;
}
- (void)splashScreenDidAppear:(PRPSplashScreen*)splashScreen {
NSLog(@"splashScreenDidAppear!");
}
- (void)splashScreenWillDisappear:(PRPSplashScreen*)splashScreen {
NSLog(@"splashScreenWillDisappear!");
}
- (void)splashScreenDidDisappear:(PRPSplashScreen*)splashScreen {
self.splashScreen = nil;
}
- (void)dealloc {
[windowrelease], window = nil;
[navControllerrelease], navController = nil;
[splashScreenrelease], splashScreen = nil;
[superdealloc];
}
[/b]
原文地址:http://www.cocoachina.com/bbs/read.php?tid=73570&page=1
相关文章推荐
- C#启动界面制作
- Android开发笔记--制作启动界面splash
- 用html5和js制作一个游戏启动界面(html5游戏开发一)、
- 启动界面的制作
- 两行命令从png制作启动界面initlogo.rle
- Delphi : 制作程序启动欢迎界面
- MFC-->制作程序启动界面
- 特殊类型窗体制作: 用C#实现启动欢迎界面
- ipad/iphone启动界面Default.png
- 安卓入门:启动界面制作
- Iphone软件启动界面详解
- 两行命令从png制作启动界面initlogo.rle
- Android制作启动界面
- 孙鑫VC学习笔记:第九讲 界面修改,工具栏,状态栏,启动画面的制作
- swing制作的启动界面
- 用Qt制作mdl程序启动界面
- Android 启动界面的制作
- 使用exe4j制作Java启动程序的的等候界面
- iphone程序启动界面问题
- 使用exe4j制作java启动程序等候界面