带有 ttf 字体的 UIButton
是否可以将 UIButtons 与我自己的 true type 字体一起使用?我发现 FontLabel 开源可以将 ttf 与 UILabels 一起使用,但不幸的是我无法将 UIButton 的 titleLabel 设置为创建的 FontLabel。有人可以为此提供一个简单的解决方案吗?或者我应该不完全使用 UIButtons 而使用其他东西?我觉得我错过了一些明显的东西,因为我无法想象在某些默认按钮产品中不会有一些 truetype 功能。
Is it possible to use UIButtons with my own true type font? I found the FontLabel open source that can use ttf with UILabels, but unfortunately I can't set my UIButton's titleLabel to a created FontLabel. Can someone offer a simple solution to this? Or should I just not be using UIButtons altogether and instead use something else? I feel like I'm missing something obvious because I can't imagine there wouldn't be some truetype functionality in some default button offering.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从 3.2 SDK 开始,您可以在应用程序中包含自己的 ttf 字体。只需将字体文件包含在您的包中并将 UIAppFonts 键添加到您的 info.plist 中即可。 (http://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW18)
然后你应该能够像创建任何内置字体一样创建字体并将其用作按钮标签的字体。
As of the 3.2 SDK, you can include your own ttf fonts in your app. Just include the font file in your bundle and add the UIAppFonts key to your info.plist. (http://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW18)
You should then be able to create the font as you would any built-in font and use it as the font for your button's label.
对于那些遇到此问题并正在寻找解决方法的人,这对我有用(链接到我提出并后来回答的问题):
有关在 iPad 上调试 UIAppFonts 问题的建议
For those of you having this problem and looking for a workaround, this worked for me (link to a question I posed and later answered):
Advice on Debugging a UIAppFonts Issue on iPad