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 吗?如果我们根本不需要使用字体会更好

4

1 回答 1

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;
}
于 2013-09-27T05:03:40.040 回答