UIButton with two lines of text in the title (numberOfLines=2)

后端 未结 6 1959
面向向阳花
面向向阳花 2021-01-30 15:42

I\'m trying to make a UIButton that has two lines of text in its titleLabel. This is the code I\'m using:

    UIButton *titleButton = [[UIButton all         


        
6条回答
  •  萌比男神i
    2021-01-30 16:20

    You can do this much easier, with no code required. In Interface Builder set Line Break on UIButton to Word Wrap. Than you can insert multiple lines of title. Just hit Option + Return keys to make new line. You will also need to add this to the User Defined Runtime Attribute in Interface Builder:

    titleLabel.textAlignment Number [1]
    

    It's that simple. Hope it helps...

提交回复
热议问题