iOS Question How can I change the text color on a button? [SOLVED]

Didier9

Well-Known Member
Licensed User
Longtime User
The title says it all.
I have created red and blue buttons but the text is hardly visible. I cannot find if that can be changed.
 

Alexander Stolte

Expert
Licensed User
Longtime User
'state: 0 = normal, 1 = pressed, 2 = disabled
Sub SetButtonTextColor(btn As Button, clr As Int, state As Int)
Dim no As NativeObject = btn
no.RunMethod(
"setTitleColor:forState:", Array(no.ColorToUIColor(clr), state))
End Sub

SetButtonTextColor(Button1,
Colors.Grean, 1)

is from this post.
 
Upvote 0

mcvburen

Member
Licensed User
B4X:
Dim b As Button .
  Dim ButtonText as int = Colors.White
  Dim ButtonColor as int = Colors.Blue

   b.Color = ButtonColor
   b.SetBorder(2,ButtonColor,10)
 
   'state: 0 = normal, 1 = pressed, 2 = disabled
   Dim no As NativeObject = b
   no.RunMethod("setTitleColor:forState:", Array(no.ColorToUIColor(ButtonText), 0))
   no.RunMethod("setTitleColor:forState:", Array(no.ColorToUIColor(ButtonColor), 1))
   no.RunMethod("setTitleColor:forState:", Array(no.ColorToUIColor(Colors.Gray), 2))

This may help.
 
Upvote 0
Top