iOS Question Label Pressed Color

StephanP82

Member
Licensed User
Longtime User
Hi,

I'm trying to set Pressed- and Disabled-Colors for labels. In B4A I've used ColorDrawables and StatelistDrawable for it. How can i do in B4i?

If it's not possible, I could use a CustomButton instead but if it's Label has a long Text, it shows it with "..." in the middle. In this case I dont want to reduce the font size, I want to show the "..." at the end of the Text.
 

StephanP82

Member
Licensed User
Longtime User
Hi JanPro,

It would be nice to be able to set text and background colors for the states, but I would prefer the background color.
Do you have an idea to realize it?
 
Upvote 0

JanPRO

Well-Known Member
Licensed User
Longtime User
For a label it's not possible to set colors for a sepcific state, so you have to use a button.
If it's not possible, I could use a CustomButton instead but if it's Label has a long Text, it shows it with "..." in the middle. In this case I dont want to reduce the font size, I want to show the "..." at the end of the Text.

Here:
B4X:
    Dim NaObj As NativeObject = Button.CustomLabel
    NaObj.SetField("lineBreakMode",4)
 
Upvote 0

JanPRO

Well-Known Member
Licensed User
Longtime User
Yes:
B4X:
Sub SetPressedBackgroundColor(Color As Int, B As Button)
    Dim P As Panel
    P.Initialize("")
    P.Color = Color
    P.Width = B.Width
    P.Height = B.Height
  
    Dim C As Canvas
    C.Initialize(P)

    Dim NaObj As NativeObject = B
    NaObj.RunMethod("setBackgroundImage:forState:", Array(C.CreateBitmap, 1))
End Sub

Jan
 
Upvote 0
Top