iphone--启动界面的制作

iphone--启动界面的制作,第1张

概述第一种方式  在iphone的启动应用之前,系统会默认在Resources文件夹中的Default.png,为启动界面。 为了在iPad上使用上述的启动画面,你还需要在info.plist中加入 key: UISupportedInterfaceOrie ntations。 同时,加入值 UIInterfaceOrientationPortrait UIInterfaceOrientationPo

第一种方式 

在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, 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,系统自带的,进行加载。


自定义的显示页面

//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];
}


原文地址:http://www.cocoachina.com/bbs/read.PHP?tID=73570&page=1

总结

以上是内存溢出为你收集整理的iphone--启动界面的制作全部内容,希望文章能够帮你解决iphone--启动界面的制作所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1092362.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存