Sunday, July 7, 2013

Write a label on image

UIImageView *imagePinViewA = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"PIN_green"]];
UILabel *pinLabelA = [[UILabel alloc] initWithFrame:CGRectMake(8.6, 9, 26, 26)];
pinLabelA.backgroundColor = [UIColor clearColor];
pinLabelA.textColor = [UIColor blackColor];
pinLabelA.text = @"TEXT";
[imagePinViewA addSubview:pinLabelA];

UIGraphicsBeginImageContext(imagePinViewA.bounds.size);
[imagePinViewA.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *finalImagePinA = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();