About a year ago @JordiCP made a nice solution for adjusting the link color in textviews. It can be found here:
However, he hardcoded the colors in the OBJC code, and I would like them to be inputs instead. I have tried for almost a full day to achieve this seemingly basic adjustment but I just can't seem to figure it out. Therefore I'm asking if someone in the forum can help out?
In my situation I actually have the colors defined as hex strings, but I can easily convert them to ints using this function by Erel:
This is how far I've come by searching the interwebs and the stack overflows, which is not a working solution:
(The 16711680 is simply #FF0000 as Int, hardcoded at the moment while testing.)
The error for the above is...
...so I assume there is something I just don't understand when it comes to the OBJC parameters.
[SOLVED] CSBuilder clickable link color in B4i. How to change it?
I wanted to update an already existing B4i app and thought it wouldn't take me much ?...but here I am. In this version, some explanatory texts are to be added to a TextView, and some parts of which should be clickable. So I thought of using CSBuilder. However, by design, the clickable parts...
www.b4x.com
However, he hardcoded the colors in the OBJC code, and I would like them to be inputs instead. I have tried for almost a full day to achieve this seemingly basic adjustment but I just can't seem to figure it out. Therefore I'm asking if someone in the forum can help out?
In my situation I actually have the colors defined as hex strings, but I can easily convert them to ints using this function by Erel:
[B4X] HexToColor and ColorToHex
Converts hex color strings to a color int value and vice versa: Private Sub ColorToHex(clr As Int) As String Dim bc As ByteConverter Return bc.HexFromBytes(bc.IntsToBytes(Array As Int(clr))) End Sub Private Sub HexToColor(Hex As String) As Int Dim bc As ByteConverter If...
www.b4x.com
This is how far I've come by searching the interwebs and the stack overflows, which is not a working solution:
B4X:
Me.As(NativeObject).RunMethod("changeTextViewLinkAttributes:", Array(myTextView, 16711680, 16711680))
Objective-C:
#if OBJC
-(void) changeTextViewLinkAttributes:(UITextView *) textView: (int) linkColor: (int) underlineColor {
NSDictionary *linkAttributes = @{
NSForegroundColorAttributeName:
[UIColor
colorWithRed:((float)((linkColor & 0xFF0000) >> 16))/255.0 \
green:((float)((linkColor & 0x00FF00) >> 8))/255.0 \
blue:((float)((linkColor & 0x0000FF) >> 0))/255.0 \
alpha:1.0],
NSUnderlineColorAttributeName:
[UIColor
colorWithRed:((float)((underlineColor & 0xFF0000) >> 16))/255.0 \
green:((float)((underlineColor & 0x00FF00) >> 8))/255.0 \
blue:((float)((underlineColor & 0x0000FF) >> 0))/255.0 \
alpha:1.0],
NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)
};
textView.linkTextAttributes = linkAttributes;
}
#End If
The error for the above is...
B4X:
Method not found: changeTextViewLinkAttributes: <snip>