Search code examples
cosmicmind

FlatButton height to titleLabel


I'm trying to make the height of a FlatButton to the height of the label inside the FlatButton.

var textButton: FlatButton = FlatButton()
textButton.contentEdgeInsets = UIEdgeInsetsZero

But that does only get rid of the spacing on the left and right. There is still spacing on top and bottom. How can I make the button no bigger than the text?


Solution

  • Maybe a bug in ios, but this is a workaround:

    var textButton: FlatButton = FlatButton()
    textButton.contentEdgeInsets = UIEdgeInsets(top: 1, left: 0, bottom: 1, right: 0)
    

    This actually makes the button smaller than if I do

    UIEdgeInsets(top: 0, left: 0, bottom: , right: 0)