Wednesday 4 January 2012

SplashView in iPhone

///Put Bellow Code in AppDelegate.m File
///viewLoad

mySplash = [[SplashView alloc] initWithImage:[UIImage imageNamed:@"default.jpg"]];
mySplash.animation = SplashViewAnimationFade;
mySplash.delay = 0.1;
mySplash.touchAllowed = YES;
mySplash.delegate = self;
[self performSelector:@selector(splashIsDone) withObject:nil afterDelay:2.0];
    [self.window addSubview:mySplash];

///afetr put this method

#pragma mark -
#pragma mark SplashView Delegate

- (void)splashIsDone {

    logo= [[logoview alloc]initWithNibName:@"logoview" bundle:nil];
    [self.window addSubview:logo.view];
// [self.window addSubview:tabBarController.view];
[mySplash removeFromSuperview];
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setType:kCATransitionFade];
[animation setDuration:1];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:
  kCAMediaTimingFunctionEaseInEaseOut]];
[[self.window layer] addAnimation:animation forKey:@"animateTransform"];
}

///////Splash.h file......

//
//  splashView.h
//  version 1.1
//
//  Created by Shannon Appelcline on 5/22/09.
//  Copyright 2009 Skotos Tech Inc.
//
//  Licensed Under Creative Commons Attribution 3.0:
//  You may freely use this class, provided that you maintain these attribute comments
//
//  Visit our iPhone blog: http://iphoneinaction.manning.com
//

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

@protocol SplashViewDelegate <NSObject>
@optional
- (void)splashIsDone;
@end

typedef enum {
SplashViewAnimationNone,
SplashViewAnimationSlideLeft,
SplashViewAnimationFade,
} SplashViewAnimation;
@interface SplashView : UIView {

id<SplashViewDelegate> delegate;
UIImageView *splashImage;
UIImage *image;
NSTimeInterval delay;
BOOL touchAllowed;
SplashViewAnimation animation;
NSTimeInterval animationDelay;
BOOL isFinishing;
}
@property (retain) id<SplashViewDelegate> delegate;
@property (retain) UIImage *image;
@property NSTimeInterval delay;
@property BOOL touchAllowed;
@property SplashViewAnimation animation;
@property NSTimeInterval animationDelay;
@property BOOL isFinishing;

- (id)initWithImage:(UIImage *)screenImage;

@end

///SplashView.m.....

//
//  splashView.m
//  version 1.1
//
//  Created by Shannon Appelcline on 5/22/09.
//  Copyright 2009 Skotos Tech Inc.
//
//  Licensed Under Creative Commons Attribution 3.0:
//  You may freely use this class, provided that you maintain these attribute comments
//
//  Visit our iPhone blog: http://iphoneinaction.manning.com
//

#import "SplashView.h"
#import <QuartzCore/QuartzCore.h>

@implementation SplashView

@synthesize delegate;
@synthesize image;
@synthesize delay;
@synthesize touchAllowed;
@synthesize animation;
@synthesize isFinishing;
@synthesize animationDelay;

- (id)initWithImage:(UIImage *)screenImage {
if (self = [super initWithFrame:[[UIScreen mainScreen] applicationFrame]]) {
self.image = screenImage;
self.delay = 2;
self.touchAllowed = NO;
self.animation = SplashViewAnimationNone;
self.animationDelay = .5;
self.isFinishing = NO;
splashImage = [[UIImageView alloc] initWithImage:self.image];
[self addSubview:splashImage];
}
return self;
}

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag {
[self removeFromSuperview];
}

//- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
//
// if (self.touchAllowed) {
// if (self.delegate != NULL && [self.delegate respondsToSelector:@selector(splashIsDone)]) {
// [delegate splashIsDone];
// }
// }
//}

- (void)dealloc {
    [super dealloc];
}


@end





No comments:

Post a Comment