قالب وردپرس درنا توس
Home / IOS Development / How to change iOS button size based on titleLabel length: iOSProgramming

How to change iOS button size based on titleLabel length: iOSProgramming



My buttons do not change based on the text in title tag. All title tag text appears, but it goes beyond the button's boundaries.

My buttons are in a stack view in an xib cell. The Xib cell also has a label over the stability view.

I have two classes: ViewController (table view and data source), ViewCell (buttons and actions)

ViewController code: In my cellForRowAt method:

cell.choice1Button Title cell.choice3Button.titleLabel? .numberOfLines = 0

cell.conceptLabel.text = question [“concept”]!

cell.choice1Button.setTitle (the question [“choice1

”]!, For: normal)

cell.choice2Button .setTitle (the question [“choice2”]!, For: normal)

cell.choice3Button.setTitle (the question [“choice3”]!, For: normal.

I want the buttons to change the size in height and for the text to wrap based on how long the title tag text is. Is this a limitation question?


Source link