久久精品精选,精品九九视频,www久久只有这里有精品,亚洲熟女乱色综合一区
    分享

    iPhone開發之啟動畫面及動畫

     命運之輪 2012-10-15

    一、靜態圖片的設置

    iOS設備現在有三種不同的分辨率:iPhone 320x480iPhone 4 640x960、iPad 768x1024。以前程序的啟動畫面(圖片)只要準備一個 Default.png就可以了,但是現在變得復雜多了。下面就是 CocoaChina 會員做得總結

      如果一個程序,既支持iPhone又支持iPad,那么它需要包含下面幾個圖片:

    Default-Portrait.png iPad專用豎向啟動畫面 768x1024或者768x1004

    Default-Landscape.png iPad專用橫向啟動畫面 1024x768或者1024x748

    Default-PortraitUpsideDown.png iPad專用豎向啟動畫面(Home按鈕在屏幕上面),可省略 768x1024或者768x1004

    Default-LandscapeLeft.png iPad專用橫向啟動畫面,可省略 1024x768或者1024x748

    Default-LandscapeRight.png iPad專用橫向啟動畫面,可省略 1024x768或者1024x748

    Default.png iPhone默認啟動圖片,如果沒有提供上面幾個iPad專用啟動圖片,則在iPad上運行時也使用Default.png(不推薦) 320x480或者320x460

    Default@2x.png iPhone4啟動圖片640x960或者640x920

     

      為了在iPad上使用上述的啟動畫面,你還需要在info.plist中加入key: UISupportedInterfaceOrientations。同時,加入值UIInterfaceOrientationPortrait, UIInterfacOrientationPortraitUpsideDown, UIInterfaceOrientationLandscapeLeft, UIInterfaceOrientationLandscapeRight。

     

    二、設置靜態圖片停留的時間

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions中使用下面集中方法都可以:

    1、sleep(3);

    2、[NSThread sleepForTimeInterval:5.0];

    3、[selfperformSelector:@selector(startupview)withObject:nilafterDelay:3];

     

    三、設置啟動動畫

    在appDelegate中加載啟動動畫的controller,在開啟動畫的controller中載入首頁controller,通過透明度來設置淡入和淡出。

    appDelegate.h

    復制代碼
    #import <UIKit/UIKit.h>
    #import "Startupscreen.h"
    
    @interface AppDelegate : UIResponder <UIApplicationDelegate> {
         Startupscreen *startupscreen;
    }
    
    @property (strong, nonatomic) UIWindow *window;
    @property (nonatomic, retain) Startupscreen *startupscreen;
    
    @end
    復制代碼

    appDelegate.m

    復制代碼
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        NSLog(@"didFinishLaunchingWithOptions");
        self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
        startupscreen = [[Startupscreen alloc] initWithNibName:@"Startupscreen" bundle:nil];
        [self.window addSubview:startupscreen.view];
        [self.window makeKeyAndVisible];
        return YES;
    }
    復制代碼

    Startupscreen.h

    復制代碼
    #import <UIKit/UIKit.h>
    #import "ViewController.h"
    
    @interface Startupscreen : UIViewController{
    
        NSTimer *timer;
        UIImageView *splashImageView;
        UINavigationController *nav;
        ViewController *myviewcontroller;
    }
    
    @property (nonatomic,retain) NSTimer *timer;
    @property (nonatomic,retain) UIImageView *splashImageView;
    @property (nonatomic,retain) UINavigationController *nav;
    @property (nonatomic,retain) ViewController *myviewcontroller;
    
    @end
    復制代碼

    Startupscreen.m

    復制代碼
    #import "Startupscreen.h"
    #import "ViewController.h"
    
    @interface Startupscreen ()
    
    @end
    
    @implementation Startupscreen
    @synthesize timer;
    @synthesize splashImageView;
    @synthesize nav;
    @synthesize myviewcontroller;
    
    
    
    int flag;
    NSTimer *timer;
    
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            // Custom initialization
        }
        return self;
    }
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        // Do any additional setup after loading the view from its nib.
            CGRect appFrame = [[UIScreen mainScreen] applicationFrame];
            UIView *view = [[UIView alloc] initWithFrame:appFrame];
            view.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
            self.view = view;
            [view release];
        
        
        
        flag = 0;
        
        splashImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"c618Default1.png"]];
        splashImageView.frame = CGRectMake(0, 0, 768, 1004);
        [self.view addSubview:splashImageView];
    
        timer = [NSTimer scheduledTimerWithTimeInterval:0.6 
                                                 target:self 
                                               selector:@selector(addLabel) 
                                               userInfo:nil 
                                                repeats:YES];
        
        myviewcontroller = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
        myviewcontroller.view.alpha = 0.0;
        //[self.view addSubview:myviewcontroller.view];
        nav = [[UINavigationController alloc] init];
        [nav pushViewController:myviewcontroller animated:NO];
        [self.view addSubview:nav.view];
        
        
        timer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(fadeScreen) userInfo:nil repeats:NO];
       
        
        
    }
    
    - (void)addLabel{
        
        flag++;
        if (flag <=5) {
            UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(200+50*flag,600,40, 40)];
            label1.text = @"123";
            label1.font = [UIFont systemFontOfSize:23];
            label1.textColor = [UIColor whiteColor];
            [self.view addSubview:label1];
            [label1 release];
        }
        
    }
    
    - (void)fadeScreen
    {
        [UIView beginAnimations:nil context:nil]; // begins animation block
        [UIView setAnimationDuration:0.75];        // sets animation duration
        [UIView setAnimationDelegate:self];        // sets delegate for this block
        [UIView setAnimationDidStopSelector:@selector(finishedFading)];   // calls the finishedFading method when the animation is done (or done fading out)    
        self.view.alpha = 0.0;       // Fades the alpha channel of this view to "0.0" over the animationDuration of "0.75" seconds
        [UIView commitAnimations];   // commits the animation block.  This Block is done.
    }
    
    
    - (void) finishedFading
    {
        
        [UIView beginAnimations:nil context:nil]; // begins animation block
        [UIView setAnimationDuration:0.75];        // sets animation duration
        self.view.alpha = 1.0;   // fades the view to 1.0 alpha over 0.75 seconds
        myviewcontroller.view.alpha = 1.0;
        [UIView commitAnimations];   // commits the animation block.  This Block is done.
        
        for(UIView *mylabelview in [self.view subviews])
        {
            if ([mylabelview isKindOfClass:[UILabel class]]) {
                [mylabelview removeFromSuperview];
            }
        }
        
        [splashImageView removeFromSuperview];
    }
    復制代碼

    上述代碼實現了一個簡單的進度啟動動畫,供大家參考。

      本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發布,不代表本站觀點。請注意甄別內容中的聯系方式、誘導購買等信息,謹防詐騙。如發現有害或侵權內容,請點擊一鍵舉報。
      轉藏 分享 獻花(0

      0條評論

      發表

      請遵守用戶 評論公約

      類似文章 更多

      主站蜘蛛池模板: 又大又粗又硬放不进去了| 67194熟妇在线观看线路| 亚洲国产精品久久久天堂麻豆宅男| 婷婷色爱区综合五月激情韩国| 日本不卡一区二区三区| 熟女一区二区中文字幕| 免费无码成人AV片在线在线播放| 综合偷自拍亚洲乱中文字幕| 97夜夜澡人人爽人人模人人喊| 亚洲精品V天堂中文字幕| 宅男噜噜噜66在线观看| 激情内射亚洲一区二区三区爱妻| 少妇无套内谢免费视频| 日日摸夜夜添狠狠添欧美| 在国产线视频A在线视频| 精品一区二区三区无码视频| 欧美高清狂热视频60一70| 精品久久久久久无码人妻热| 最新国产AV最新国产在钱| 国产精品亚洲LV粉色| 无码成人午夜在线观看| 无码人妻丝袜在线视频| 国产综合久久亚洲综合| 国产成人亚洲综合图区| 亚州少妇无套内射激情视频| 欧美熟妇乱子伦XX视频| 国99久9在线 | 免费| 久久伊人色AV天堂九九小黄鸭| 人妻精品动漫H无码中字| 伊人久久综合无码成人网| 国产香蕉一区二区三区在线视频| 少妇人妻偷人偷人精品| 色婷婷综合久久久久中文字幕| 在线理论三级午夜电影| 国产中文字幕精品视频| 美女内射视频WWW网站午夜| 亚洲WWW永久成人网站| 午夜精品福利亚洲国产| 亚洲人成色99999在线观看| 特级毛片A级毛片免费播放| 正在播放的国产A一片|