Wednesday, November 16, 2011

Create rounded corner UIWebView


// This is required for CALayer properties

#import "QuartzCore/QuartzCore.h"


    // Create UIWebview Object
    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(5, 20, 310, 220)];

    // Create Rounded corners using CALayer property
    [[webView layer] setCornerRadius:10];
    [webView setClipsToBounds:YES];

    // Set colored border using CALayer property I have set it to white
    [[webView layer] setBorderColor:
     [[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1] CGColor]];

    [[webView layer] setBorderWidth:2.75];

    [[self view] addSubview:webView];

Friday, September 30, 2011

Convert NSString to NSDate


    NSString *dateString = @"03-Sep-11";

    NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init]   autorelease];
    dateFormatter.dateFormat = @"dd-MMM-yy";

    NSDate *date = [dateFormatter dateFromString:dateString];

Thursday, September 29, 2011

Add Background Image (UIImage) To UIView


//To add a image as background for an UIView (Make sure the image is in your app’s resource bundle)
         
      - (void)viewDidLoad
      {
          self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"bgImage.png"]];
      }

xCode iOS: Set Status Bar Color and Background


User can put this code or in AppDelegate file as this will be called once in Application /Or as per requirements.

UIApplication Class
Set one of the following as per your choice:

[[UIApplication sharedApplication]
      setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO];
[[UIApplication sharedApplication]
      setStatusBarStyle:UIStatusBarStyleBlackOpaque animated:NO];
[[UIApplication sharedApplication]
      setStatusBarStyle:UIStatusBarStyleDefault animated:NO];