获取rightBarButtonItem的字体大小

时间:2018-08-14 20:56:36

标签: ios swift uibarbuttonitem

我将为rightBarButtonItem使用自定义字体,但是我想获取当前用于设置该字体大小为自定义字体大小的字体。

let myButton = UIBarButtonItem(title: "Button",
                               style: .plain,
                               target: self,
                               action:#selector(MyVC.buttonTapped(_:)))

navigationItem.rightBarButtonItem = myButton

let size = myButton...???

myButton.setTitleTextAttributes([NSAttributedStringKey.font: UIFont(name: "SomeCustomFont", size: size)! ], for: .normal)

有什么主意吗?或其他方法?

1 个答案:

答案 0 :(得分:0)

您可以获取Lazy<Task<T>>的大小,如下所示:

UIBarButtonItem