简体   繁体   English

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

[英]UITableViewRowAction customise title font size in Swift

I have an edit and a delete tableViewRowAction in my tableViewCell. 我在tableViewCell中有一个编辑和一个删除tableViewRowAction。 Currently I'm using the built in emojis to use as my title, but it is too small. 目前,我正在使用内置的表情符号作为标题,但是它太小了。 How do I make the font larger? 如何放大字体?

I know we can only customise a limited amount of things in the tableViewRowAction. 我知道我们只能在tableViewRowAction中自定义数量有限的东西。 But is there a way to go around it to make just the title font bigger? 但是有没有办法解决这个问题,以使标题字体变大?

I checked other threads and most of them used: 我检查了其他线程,其中大多数使用了:

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

with a set attribute that determines the font size of course. 带有一个确定属性的字体属性。 However, this affects ALL buttons, and that isn't good. 但是,这会影响所有按钮,这并不好。

Any help is much appreciated! 任何帮助深表感谢! Thanks! 谢谢!

you are setting this to UIButton so it is set for all UIButton objects. 您将其设置为UIButton以便为所有UIButton对象设置。

You can set it for specific button object like, 您可以将其设置为特定的按钮对象,例如,

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

Update : 更新:

You can set title as attributed string. 您可以将标题设置为属性字符串。

check Apple documentation for that and refer this answer for more details 请查阅Apple文档以获取更多信息,并参考此答案

Hope this will help :) 希望这会有所帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM