1

I have an edit and a delete tableViewRowAction in my tableViewCell. 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. 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!

Raymond Moay
  • 321
  • 1
  • 4
  • 16

1 Answers1

0

you are setting this to UIButton so it is set for all UIButton objects.

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

Hope this will help :)

Community
  • 1
  • 1
Ketan Parmar
  • 27,092
  • 9
  • 50
  • 75
  • Hi thanks for the reply. (: However, UITableViewRowAction is not of type UIButton. So I can't use the UIButton route to set the title size. – Raymond Moay May 13 '16 at 06:26
  • Thanks! I understand but how do I set title which is of type String to a NSAttributedString? It gives me an error. Here is my code: `let attributes = [NSFontAttributeName: UIFont.systemFontOfSize(20)] as Dictionary! let attributedStringRemove = NSAttributedString(string: "✖︎", attributes: attributes)` and then adding attributed string into title here: `let removeAction = UITableViewRowAction(style: .Default, title: attributedStringRemove)` – Raymond Moay May 13 '16 at 08:01
  • You're welcome!! Yes, that means you have to used default font size then. If you are not allowed to set attributed text then you can't change title implicitly. I suggest you to use `delete` or `remove` kind of text instead of `x` so that it shows some bigger effect. – Ketan Parmar May 13 '16 at 09:32