Saturday, May 12, 2012

ImageView with Border iPhone

UIImageView *imageView=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
UIImage *img = [UIImage imageNamed:@"image.png"];
imgView.image = img;


imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.layer.cornerRadius = 5;
imageView.layer.borderWidth = 1.0f;
CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
CGFloat values[4] = {0.5, 0.5, 0.5, 1.0}; 
CGColorRef grey = CGColorCreate(space, values); 
imageView.layer.borderColor = grey ;
CGColorRelease(grey);
CGColorSpaceRelease(space);

Label for iPhone

    UILabel *timeTaken = [[UILabel alloc]initWithFrame:CGRectMake(230, 50, 70, 20)];
    timeTaken.text = @"Praveen";
    timeTaken.textAlignment = UITextAlignmentLeft;
    timeTaken.textColor = [UIColor blackColor];
    timeTaken.lineBreakMode = UILineBreakModeMiddleTruncation;
    timeTaken.numberOfLines =0;
    timeTaken.tag= 9;
    timeTaken.backgroundColor = [UIColor clearColor];
    [ timeTaken setFont:[UIFont boldSystemFontOfSize:12]];// fontWithName:@"Courier" size:13]];
    [self.view addSubview: timeTaken];
    [ timeTaken release];