DLRadioButton icon indicating copy to clipboard operation
DLRadioButton copied to clipboard

Multiline buttons

Open timautin opened this issue 6 years ago • 2 comments

When having multiline buttons, the text of the titleLabel grows outside of the button. I solved it by adding a few auto layout constraints (using a custom extension but you'll get the idea):

radioButton.titleLabel!.translatesAutoresizingMaskIntoConstraints = false;
radioButton.imageView!.translatesAutoresizingMaskIntoConstraints = false;
radioButton.constrain(soThat: .height, of: radioButton, is: .greaterThanOrEqual, to: .height, of: radioButton.titleLabel);
radioButton.constrain(soThat: .trailing, of: radioButton.titleLabel!, is: .equal, to: .trailing, of: radioButton);
radioButton.constrain(soThat: .width, of: radioButton.imageView!, is: .equal, to: radioButton.iconSize);

timautin avatar May 26 '18 02:05 timautin

Or you can put all buttons in a Stackview, select Word Wrap on the Line Break each button's option and give Stackview specific width, at least that worked for me.

nikoagge avatar May 26 '18 06:05 nikoagge

Ah yes, simpler solution for those targeting iOS 9. I can't use it since I still support iOS 8.

timautin avatar May 26 '18 11:05 timautin