-(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;
}
此代码存在一些问题....
我希望方法返回“font”。我们有CFAutoRelease吗?如果我们根本不需要使用字体,那就更好了
答案 0 :(得分:4)
- (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;
}