gpt4 book ai didi

iOS UIFont 缓存?

转载 作者:技术小花猫 更新时间:2023-10-29 10:12:59 27 4
gpt4 key购买 nike

我想知道是否应该缓存 [UIFont fontWithName:@"myfont"size:24]。我在很多地方重复使用这种字体。我想知道 iOS 是否已经为我缓存了这个,因为字体缓存在操作系统级别非常普遍。

有人可以对此发表评论吗?

谢谢。

最佳答案

I am wondering if iOS is already caching this for me because font caching is very common at OS level.

这就是 iOS(我只在 iOS 6.1 上测试过)所做的。

我只是想实现自己的缓存。你知道,因为我是个聪明人,字体加载可能不是很快。

事实证明,Apple 的员工也很聪明。 fontWithName:size: 返回的对象对于相同的 fontNames 和相同的大小是相同的。有一个缓存机制。

为了确认这一点,我在整个应用程序中放置了几个 NSLog。

NSLog(@"GillSans 12 %p", [UIFont fontWithName:@"GillSans" size:12.0f]);

它们都显示相同的内存地址。

也适用于您的自定义字体。

关于iOS UIFont 缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7641549/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com