iPhone slider Game !!
iPhone racing Game !!
Saturday, September 5, 2009
Friday, September 4, 2009
Thursday, September 3, 2009
Rotate an Image using Core Graphics in iPhone!!!
UIImage* rotatingImage = [UIImage imageNamed:@"someImage.png"];
CATransform3D rotationTransform = CATransform3DMakeRotation(1.0f * M_PI, 0, 0, 1.0);
CABasicAnimation* rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
rotationAnimation.toValue = [NSValue valueWithCATransform3D:rotationTransform];
rotationAnimation.duration = 0.25f;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = 10;
[rotatingImage.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
A Category on iPhone NavigationBar to set image in background!!!
-(void)setBackgroundImage:(UIImage*)image withTag:(NSInteger)bgTag{
if(image == NULL){ //might be called with NULL argument
return;
}
UIImageView *aTabBarBackground = [[UIImageView alloc]initWithImage:image];
aTabBarBackground.frame = CGRectMake(0,0,self.frame.size.width,self.frame.size.height);
aTabBarBackground.tag = bgTag;
[self addSubview:aTabBarBackground];
[self sendSubviewToBack:aTabBarBackground];
[aTabBarBackground release];
}
/* input: The tag you chose to identify the view */
-(void)resetBackground:(NSInteger)bgTag {
[self sendSubviewToBack:[self viewWithTag:bgTag]];
}
After That call the method like:[navigationControllerForChannels.navigationBar setBackgroundImage:[UIImage imageNamed:@"top_bar.png"] withTag:48151623];After any Modification to the Bar call:[self.navigationController.navigationBar resetBackground:48151623];
Wednesday, September 2, 2009
Make iPhone NavigationBar of Custom Color!!!
navigationBar.tintColor = [UIColor colorWithRed:.7 green:.5 blue:.2 alpha:1];
Very simple rules for memory management in iPhone
In iPhone Development You must do your own memory management through reference counting, using -retain, -release and -autorelease.
Retain Count rules
- Within a given block, the use of
-copy,-allocand-retainshould equal the use of-releaseand-autorelease. - Objects created using convenience constructors (e.g. NSString's stringWithString) are considered autoreleased.
- Implement a
-deallocmethod to release the instance variables you own.
| Method | Description |
|---|---|
-retain | increases the reference count of an object by 1 |
-release | decreases the reference count of an object by 1 |
-autorelease | decreases the reference count of an object by 1 at some stage in the future |
-alloc | allocates memory for an object, and returns it with retain count of 1 |
-copy | makes a copy of an object, and returns it with retain count of 1 |
To set an image as background of iPhone UIView!!
Include an image of png extension in your project bundle and paste following line of code with your image name in viewDidLoad....
NSString *backgroundPath = [[ NSBundle mainBundle ] pathForResource : @"login" ofType : @"png" ];
UIImage *backgroundImage = [ UIImage imageWithContentsOfFile :backgroundPath];
UIColor *backgroundColor = [[ UIColor alloc ] initWithPatternImage :backgroundImage];
self .view.backgroundColor = backgroundColor;
[backgroundColor release ];
Saturday, August 29, 2009
iPhone Navigation Bar Black and Transparent!!!
@interface MyViewController ()
NSTimer *fadeTimer;
@property (nonatomic, retain) NSTimer *fadeTimer;
- (void) fadeBarController;
- (void) fadeBarAway:(NSTimer *)timer;
- (void) fadeBarIn;
@end
@implementation MyViewController
@synthesize fadeTimer;
#pragma mark -
#pragma mark View Lifecycle
-(void) viewWillAppear:(BOOL)animated {
[[UIApplication sharedApplication]
setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated: YES];
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
}
- (void) viewDidAppear:(BOOL)animated {
[self fadeBarController];
}
- (void) viewDidDisappear:(BOOL)animated {
[self.fadeTimer invalidate];
}
- (void)dealloc {
[fadeTimer release];
}
#pragma mark -
#pragma mark Fade In/Out code
- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event {
[super touchesEnded: touches withEvent: event];
[self fadeBarController];
}
- (void)fadeBarController {
if (self.navigationController.navigationBar.alpha == 0)
{
[self fadeBarIn];
}
if (self.fadeTimer != nil)
{
[self.fadeTimer invalidate];
}
self.fadeTimer = [NSTimer
scheduledTimerWithTimeInterval:kNavigationBarFadeDelay target:self
selector:@selector(fadeBarAway:) userInfo:nil repeats:NO];
}
- (void)fadeBarAway:(NSTimer*)timer {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.35];
self.navigationController.navigationBar.alpha = 0.0;
[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
[UIView commitAnimations];
}
- (void)fadeBarIn {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.35];
self.navigationController.navigationBar.alpha = 1.0;
[[UIApplication sharedApplication] setStatusBarHidden:NO animated:YES];
[UIView commitAnimations];
}
@end
Subscribe to:
Posts (Atom)

