tufanv Expert Licensed User Longtime User Jan 25, 2017 #1 Hello Is it possible to change the color of button via code ? In one of my apps I am changing all buttons to this one but for example if the button is enabled i make the color green if not i make it red. But i couldnt find a way to change the color. Thanks
Hello Is it possible to change the color of button via code ? In one of my apps I am changing all buttons to this one but for example if the button is enabled i make the color green if not i make it red. But i couldnt find a way to change the color. Thanks
Erel B4X founder Staff member Licensed User Longtime User Jan 25, 2017 #2 You can use this code: Code: Copy Sub ChangeColors(pb As PressableButton, ButtonColor As Int, ShadowColor As Int) Dim no As NativeObject = pb no.RunMethod("SetColorsWithButton:shadow:", Array(no.ColorToUIColor(ButtonColor), no.ColorToUIColor(ShadowColor))) End Sub Upvote 0
You can use this code: Code: Copy Sub ChangeColors(pb As PressableButton, ButtonColor As Int, ShadowColor As Int) Dim no As NativeObject = pb no.RunMethod("SetColorsWithButton:shadow:", Array(no.ColorToUIColor(ButtonColor), no.ColorToUIColor(ShadowColor))) End Sub