iOS Question GetButtonTextColor ? [Resolved]

Discussion in 'iOS Questions' started by stingrae, Feb 12, 2019.

  1. stingrae

    stingrae Member Licensed User

    Hi,

    I'm using the function below to set the Text Colour of a button. But I can't seem to figure out how to re-engineer it to Get the text button's colour.

    (basically I want to set Button1's TextColor property to be the same as Button2)

    Can someone help me out please? :)

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

    Erel Administrator Staff Member Licensed User

    Untested code:
    Code:
    Sub GetButtonTextColor(btn As Button, State As Int) As Int
    ' state: 0 = normal, 1 = pressed, 2 = disabled
    Dim no As NativeObject = btn
    Return no.UIColorToColor(no.RunMethod("titleColorForState:"Array(state)))
    End Sub
     
    stingrae likes this.
  3. stingrae

    stingrae Member Licensed User

    Worked PERFECTLY :)
    Thank you
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice