UITableViewRowAction在Swift中自定义标题字体大小

问题描述:

我在tableViewCell中编辑和删除了tableViewRowAction。目前我使用内置的emojis作为我的标题,但它太小了。如何使字体变大?UITableViewRowAction在Swift中自定义标题字体大小

我知道我们只能在tableViewRowAction中定制有限数量的东西。但是有没有办法绕过它来让标题字体更大?

我检查其他线程,其中大部分用于:

UIButton.appearance().setAttributedTitle(NSAttributedString(string: "Your Button", attributes: attributes), forState: .Normal) 

与确定过程的字体大小的一组属性。但是,这会影响所有按钮,这并不好。

任何帮助非常感谢!谢谢!

您正在将其设置为UIButton,因此它为所有UIButton对象设置。

你可以将它设置为如特定按钮对象,

let myButton: UIButton = UIButton() //your button here 
    let attributedStr: NSAttributedString = NSAttributedString() 
    myButton.setAttributedTitle(attributedStr, forState: .Normal) 

更新:

您可以设置标题属性串。

对于检查Apple documentation和参考this answer更多细节

希望这将有助于:)

+0

嗨感谢您的答复。 (:但是,UITableViewRowAction不是UIButton类型,所以我不能使用UIButton路径来设置标题大小。 –

+0

检查我的更新回答 – Lion

+0

谢谢!我明白,但我该如何设置字符串类型的标题为NSAttributedString?它给我一个错误。这是我的代码:'let attributes = [NSFontAttributeName:UIFont.systemFontOfSize(20)] as Dictionary! let attributedStringRemove = NSAttributedString(string:“✖︎”,attributes:attributes)'和然后在这里添加属性字符串到标题:'let removeAction = UITableViewRowAction(style:.Default,title:attributedStringRemove)' –