iPhone 上的斜体、粗体和下划线字体
如何将字体设置为粗体和斜体。有一个boldSystemFontOfSize和italicSystemFoneOfSize,但我看不到将字体设置为斜体和粗体的方法。
作为第二个问题,有没有办法在字体上设置下划线,或者只是在文本下画一条线。
How do you set a font to be both bold and italic. There is a boldSystemFontOfSize and italicSystemFoneOfSize, but I can't see the way to set a font to be both italic and bold.
As a second question, is there a way to set an underline on a font, or do you simply draw a line under text.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您实际上必须要求字体的粗体、斜体版本。例如:
要获取 iPhone 上可用的所有内容的列表,请将这个小片段放入您的
applicationDidFinishLaunching:
委托方法中并查看日志输出:注意:有些字体名称显示“oblique” - 这是与斜体相同。
我看不到做下划线的内置方法 - 你可能必须自己画线。
You have to actually ask for the bold, italic version of a font. For example:
To get a list of everything available on the iPhone, put this little snippet in your
applicationDidFinishLaunching:
delegate method and look at the log output:Note: Some font names say "oblique" - this is the same as italic.
I can't see a built-in way of doing underlines - you may have to draw the line yourself.
我最近写了一篇关于 UIFont API 的限制以及如何解决的博文。
您可以在 http://eclipsesource.com 看到它/blogs/2012/07/26/uifont-from-a-css-definition/
使用我在那里提供的代码,您可以轻松获得所需的系统 UIFont,如下所示:
UIFont *myFont = [FontResolver fontWithDescription:@“字体系列:无衬线;字体粗细:粗体;字体样式:斜体;”];
I recently wrote a blog post about the restrictions of the UIFont API and how to solve it.
You can see it at http://eclipsesource.com/blogs/2012/07/26/uifont-from-a-css-definition/
With the code I provide there, you can get your desired system UIFont as easy as:
UIFont *myFont = [FontResolver fontWithDescription:@"font-family: sans-serif; font-weight: bold; font-style: italic;"];