如何在Swift中更改字母间距? [英] How to change letter spacing in Swift?

查看:278
本文介绍了如何在Swift中更改字母间距?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更改导航栏标题中的字母间距,但到目前为止我没有成功。

I'd like to change the letter spacing in the title of my navigation bar but I've had no success so far.

提前致谢。

推荐答案

您可以通过代码传递标题字符串以及一些空格(E xample)或标签( \ t)或通过以下代码:

You can set the title via code passing the title string with some blank spacing ("E x a m p l e"), or with a tab (\t) or via code like this:

 let attributedString = NSMutableAttributedString(string: "Example")
 attributedString.addAttribute(NSKernAttributeName, value:   CGFloat(1.4), range: NSRange(location: 0, length: 9))

然后将attributedString指定给你的标题。

Then you assign attributedString to your title.

这篇关于如何在Swift中更改字母间距?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆