Here is the code from my book . This is not exactly what you want to do, but it shows the technique and you will begin! Note that I'm using 79 by 27 (not sure where you got your numbers from):
UIGraphicsBeginImageContextWithOptions(CGSizeMake(79,27), NO, 0); [[UIColor blackColor] setFill]; UIBezierPath* p = [UIBezierPath bezierPathWithRect:CGRectMake(0,0,79,27)]; [p fill]; NSMutableParagraphStyle* para = [NSMutableParagraphStyle new]; para.alignment = NSTextAlignmentCenter; NSAttributedString* att = [[NSAttributedString alloc] initWithString:@"YES" attributes: @{ NSFontAttributeName:[UIFont fontWithName:@"GillSans-Bold" size:16], NSForegroundColorAttributeName:[UIColor whiteColor], NSParagraphStyleAttributeName:para }]; [att drawInRect:CGRectMake(0,5,79,22)]; UIImage* im = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); self.sw2.onImage = im;
It looks like:

source share