美文网首页
YYText源码阅读

YYText源码阅读

作者: 啵啵_long_港 | 来源:发表于2019-03-02 13:40 被阅读0次

一、基础知识

- (void)setFont:(UIFont *)font {
    [self _makeMutableAttributes];
    if (font == (id)[NSNull null] || font == nil) {
        ((NSMutableDictionary *)_attributes)[(id)kCTFontAttributeName] = [NSNull null];
    } else {
        CTFontRef ctFont = CTFontCreateWithName((__bridge CFStringRef)font.fontName, font.pointSize, NULL);
        if (ctFont) {
            ((NSMutableDictionary *)_attributes)[(id)kCTFontAttributeName] = (__bridge id)(ctFont);
            CFRelease(ctFont);
        }
    }
}
  1. CFRelease:
    If the retain count of cf becomes zero the memory allocated to the object is deallocated and the object is destroyed. If you create, copy, or explicitly retain (see the CFRetain function) a Core Foundation object, you are responsible for releasing it when you no longer need it
    如果是你创建、copy、或明确保留(explicitly retain (see the CFRetain function))的一个Core Foundation对象,你需要用CFRelease方法去释放这个Core Foundation对象。

相关文章

网友评论

      本文标题:YYText源码阅读

      本文链接:https://www.haomeiwen.com/subject/vkpeuqtx.html