Reputation: 33090
-(NSMutableAttributedString *) masBlueBoldColorString:(NSString *) theString
{
UIFont * italicSystemFont = [UIFont fontWithName:@"HelveticaNeue-Bold" size:sizeOfFonthighLightSomeStuff];
CTFontRef font = CTFontCreateWithName((__bridge CFStringRef)italicSystemFont.fontName, italicSystemFont.pointSize, NULL);
NSRange rangeHighlight = NSMakeRange(0, theString.length);
NSMutableAttributedString * mutableAttributedString = [[ NSMutableAttributedString alloc]initWithString:theString];
if (font) {
[mutableAttributedString addAttribute:(NSString *)kCTFontAttributeName value:(__bridge id)font range:rangeHighlight];
CFRelease(font);
}
return mutableAttributedString;
}
There are some problem with this code....
I want the "font" to be returned by a method. Do we have CFAutoRelease? If we do not need to use font at all it'll be even better
Upvotes: 1
Views: 78
Reputation: 57050
- (UIFont*)myFontMethod
{
return [UIFont fontWithName:@"HelveticaNeue-Bold" size:sizeOfFonthighLightSomeStuff];
}
-(NSMutableAttributedString *) masBlueBoldColorString:(NSString *) theString
{
UIFont * font = [self myFontMethod];
NSMutableAttributedString * mutableAttributedString = [[NSMutableAttributedString alloc] initWithString:theString];
if (font) {
[mutableAttributedString addAttribute:NSFontNameAttribute value:font];
}
return mutableAttributedString;
}
Upvotes: 4