Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

fabrum

macrumors member
Original poster
Jan 15, 2021
47
3
I created a button that is narrow horizontally and long vertically. I want to show text in the button that is vertical. For example,


T
h
i
s

B
u
t
t
o
n

i
s

v
e
r
t
i
c
a
l


How can I do that?
 

casperes1996

macrumors 604
Jan 26, 2014
7,494
5,667
Horsens, Denmark
You don't specify how you build the button. But generally speaking UIButton/Button will automatically adjust the text to the frame so if the frame is tall and not very wide, it will accommodate, though you may need to set the number of lines to 0 so it doesn't limit it to 1 line if it defaults to that
But you know, to just raw answer your question and show you how it can be done, void of context - this is a way

1627949524860.png
 
  • Like
Reactions: BigMcGuire

fabrum

macrumors member
Original poster
Jan 15, 2021
47
3
Thanks for replying to my thread and thank you for the suggestion! I will try it !
 

fabrum

macrumors member
Original poster
Jan 15, 2021
47
3
How do I set lines to 0 in a button? I cannot see that there is any way to do that using the Xcode inteface.
 

casperes1996

macrumors 604
Jan 26, 2014
7,494
5,667
Horsens, Denmark
How do I set lines to 0 in a button? I cannot see that there is any way to do that using the Xcode inteface.

As I was alluding to with my prior comment we’d need to know more about your development environment. Is this a SwiftUI or UIKit codebase?
If we’re talking about a UIKit UIButton then it has a titleLabel property that you can set numberOfLines on. I.e.
button.titleLabel.numberOfLines = 0
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.