-1

Ones I change the text in button it's getting stink to font size of ~18 even though initial font size is 55. Button is not custom. It has System font.

button.setTitle("Some button text", for: .normal)

I tried manually change font size in code but it doesn't help

button.titleLabel?.font = UIFont.systemFont(ofSize: 55)

I also tried to change the name through configuration function, but there is no font size and it shrinks anyway.

`

button.configuration = paperButtonConfiguration()

func buttonConfiguration() -> UIButton.Configuration {
        var config: UIButton.Configuration = .plain()
        config.title = "Some button text"
//Should probably be something like this but it doesn't work
//config.font = UIFont.systemFont(ofSize: 55)
        return config
    }

`

While I was writing this question I kind of solve this, but not completely. If I change the button style from "plain" to "default" it works, but some weird animation of fading and appearance occurs.

How could I do this with "plain"?

  • 1
    You need to post sufficient code that people can copy and paste to reproduce the issue. Without being able to see your relevant code it's very difficult to know why you are having an issue. – HangarRash Dec 01 '22 at 02:39

1 Answers1

0

UIButton has four type are Plain,Grain,Tinted,Filled .When you create a button in storyboard , button type automatically set with Plain that means new UIButton configurations is on. If you want to old behaviour , you must set style plain to default.

Or , If you want one of the style above . You need to set font like

button.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
  var outgoing = incoming
  outgoing.font = UIFont.systemFont(ofSize: 50)
  return outgoing
 }
teja_D
  • 383
  • 3
  • 18