iOS Question Button Design

Allan Cameron

Member
Licensed 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

Administrator
Staff member
Licensed User

Allan Cameron

Member
Licensed 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.
 

Filippo

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

See this thread: http://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;
 
Top