Thursday, May 2, 2013

Globally change navigation bar title color using appearance - IOS

//For Navigation BAR
  NSDictionary *text = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor GreenColor], UITextAttributeTextColor, [UIColor whiteColor], UITextAttributeTextShadowColor, nil];

    [[UINavigationBar appearance] setTitleTextAttributes:text];



//For Navigation Item


   [[UIBarButtonItem appearance] setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:
      [UIColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0],
      UITextAttributeTextColor,
      [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0],
      UITextAttributeTextShadowColor,
      [NSValue valueWithUIOffset:UIOffsetMake(0, 1)],
      UITextAttributeTextShadowOffset,
      [UIFont fontWithName:@"Helvatica" size:0.0],
      UITextAttributeFont,
      nil]  forState:UIControlStateNormal];

Friday, April 26, 2013

change a sprite image in cocos2d iOS

CCTexture2D *firstImage = [[CCTextureCache sharedTextureCache] addImage:@"Image1.png"];

CCTexture2D *secondImage = [[CCTextureCache sharedTextureCache] addImage:@"Image2.png"];

CCSprite *sprite = [CCSprite spriteWithTexture: firstImage];


[self addChild:sprite];

 change the image of the sprite to secondImage:- 
sprite.texture = secondImage;

Tuesday, April 16, 2013

Determine device (iPhone,iPad , iPod Touch) with iPhone SDK


if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        {
            NSLog(@"I'm iPad");
    } else {
    NSString *deviceType = [UIDevice currentDevice].model;
                if([deviceType rangeOfString:@"iPhone"].location!=NSNotFound)
                {
                    NSLog(@"I m iPhone");

                } else {
                    NSLog(@" I'm  iPod");

                }
}

Thursday, April 11, 2013

Point the user back to the Location Services screen in the Settings app


[[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"prefs:root=LOCATION_SERVICES"]];

Sunday, April 7, 2013

Get Custom Album name Using ALAsset Library IOS ....


 __block ALAssetsGroup* groupToAddTo;
    [self.library enumerateGroupsWithTypes:ALAssetsGroupAlbum
                                usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
                                     NSLog(@"[group valueForProperty:ALAssetsGroupPropertyName]  %@", [group valueForProperty:ALAssetsGroupPropertyName] );
                                    if ([[group valueForProperty:ALAssetsGroupPropertyName] isEqualToString:albumName]) {
                                        NSLog(@"found album %@", albumName);
                                        groupToAddTo = group;
                                    }
                                }
                              failureBlock:^(NSError* error) {
                                  NSLog(@"failed to enumerate albums:\nError: %@", [error localizedDescription]);
                              }];

Friday, April 5, 2013

Save Image to document directory IOS:-


Save Image to document directory:-

- (void)saveImage {

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.png"];
    NSLog(@"savedImagePath..%@",savedImagePath);
    NSData *imageData = UIImagePNGRepresentation(Image);
    [imageData writeToFile:savedImagePath atomically:YES];  
    
  
}

Get Original Image from Photolibrary using ALAsset IOS


Get Original Image from Photolibrary:-

 ALAssetRepresentation *rep = [[dataContainer objectAtIndex:indexPath+1] defaultRepresentation];
    CGImageRef iref = [rep fullResolutionImage];
    if (iref) {
        UIImage *image = [UIImage imageWithCGImage:iref];
    }