iPhone SDK 3.2 和 UIAppFonts
我已将自定义字体添加到 UIAppFonts 中,并且加载得很好:(显示在 [UIFont familyNames]
中)。当我在 viewDidLoad { [myLabel setFont: [UIFont fontWithName:@"CustomFont" size: 65.0]]; 中手动设置字体时} 一切正常并且字体已渲染。
然而,在 IB 中做同样的事情却不会(而是使用其他一些默认字体)。必须为每个标签创建 IBOutlet 并在 viewDidLoad 中手动修复字体是非常痛苦的。
还有其他人在使用 3.2 SDK 和 IB 获取自定义字体支持时遇到问题吗?
I've added my custom font to UIAppFonts and it's loaded just fine: (shows up in [UIFont familyNames]
). When I manually set the font in viewDidLoad { [myLabel setFont: [UIFont fontWithName:@"CustomFont" size: 65.0]]; }
everything works and the font is rendered.
However doing the same thing in IB doesn't (some other default font is used instead). Having to create IBOutlets for each label and fixing up the fonts manually in viewDidLoad is pretty painful.
Anyone else had problems getting the custom font support to work with 3.2 SDK and IB?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
向 Apple 提交了一份错误报告,结果发现这确实是一个错误。我最终使用的解决方法是这样的:
在我们的 博客。
Opened a bug report with Apple and turns out it really is a bug. The workaround I ended up using is this:
Wrote a bit longer post at our blog.
有类似的问题。并以这种方式修复它...
将我的自定义字体添加到我的资源组。然后通过下面给出的代码加载所有字体:
希望它能工作。
had simillar kind of problem.and fixed it in this way...
add my custom font to my Resource group. then load all the fonts by the code given bellow:
Hope it will work.
如果您不想子类化,那么这个解决方案对我来说既快速又肮脏。当然,它假设所有标签都具有相同的字体,在我的例子中就是这种情况。
我把它放在一个辅助类中并调用它,传递我当前的视图。
If you don't want to have to subclass, this solution worked quick and dirty for me. Of course it assumes that all labels have the same font, and in my case that was the case.
I put this in a helper class and just called it, passing in my current view.