1
-(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;
}
有一些問題,此代碼....如何讓這段代碼更優雅?
我想要的「字體」通過一個方法返回。我們有CFAutoRelease嗎?如果我們根本不需要使用字體,它會更好
你爲什麼使用CTFontRef而不是UIFont? –
你的意思是我可以使用UIFont?怎麼樣? –
'[UIFont fontWithName:@「HelveticaNeue-Bold」size:sizeOfFontthighLightSomeStuff]' 然後你不需要演員。 –