iOS Question Button Design

Allan Cameron

Member
Licensed User
Longtime User
Erel--How do I set the button text color in code? There does not seem to be a .TextColor setting. Also, is there a way to have multi-line text on a button?

Thanks

Allan
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
It should be centered by default:

SS-2014-12-11_14.35.33.png
 
Upvote 0

Allan Cameron

Member
Licensed User
Longtime User
Erel--Thanks again for your help. I have been putting labels of different lengths on buttons (in different languages) and this has sorted out the problem I was experiencing.
 
Upvote 0
D

Deleted member 103

Guest
Note that this is not a private forum. Don't limit your questions to a single member.

See this thread: https://www.b4x.com/android/forum/threads/button-textcolor.47640/#post-295034

You can use this code to set the button to show multiple lines:
B4X:
Sub SetMultiline(b As Button)
   Dim no As NativeObject = b
   no.GetField("titleLabel").SetField("numberOfLines", 0)
End Sub

TextAlignment=ALIGNMENT_CENTER
B4X:
Sub SetMultiline(b As Button)
    Dim no As NativeObject = b
    no.GetField("titleLabel").SetField("numberOfLines", 0)
    no.GetField("titleLabel").SetField("textAlignment", 1)
End Sub

Declaration
Objective-C

enum { NSTextAlignmentLeft = 0, NSTextAlignmentCenter = 1, NSTextAlignmentRight = 2, NSTextAlignmentJustified = 3, NSTextAlignmentNatural = 4, }; typedef NSInteger NSTextAlignment;
 
Upvote 0
Top