I’m using iosDesignExtensions and can’t seem to figure out what to put in my opening event for it. I tried using SetSelectedColor but it doesn’t seem to be doing anything. Any ideas?
It seems SetSelectedColorXC will only work after setting SetNormalColorXC:
me.SetNormalColorXC(color.Clear)
me.SetSelectedColorXC(&cA0A0FF)
Thanks so much, I knew there had to be something I was missing! I don’t see anything for SetSelectedTextColor, Is there a trick for that?
I think there is but it requires adding iOSKit to your project.
I will update the project on github in the coming days so it doesn’t require iOSkit anymore.
In SegmentedControlExtensionsXC.SetTextColorXC, erase all code and paste this:
Declare Function dlopen Lib “/usr/lib/libSystem.dylib” (path As CString, mode As Integer) As Ptr
Declare Function dlsym Lib “/usr/lib/libSystem.dylib” ( handle As Ptr, name As CString ) As ptr
Dim uikitHandle As Ptr = dlopen(“/System/Library/Frameworks/UIKit.framework/UIKit”, 2)
Dim symAddr As Ptr = dlsym(uikitHandle, “NSForegroundColorAttributeName”)
Dim keyStr As ptr = symAddr.Ptr(0)
Declare Function NSClassFromString Lib “Foundation” (aClassName As CFStringRef) As Ptr
Declare Function dictionaryWithObjectForKey Lib “Foundation” selector “dictionaryWithObject:forKey:” _
(clsRef As ptr, obj As ptr, key As ptr) As ptr
Dim nsDic As ptr = dictionaryWithObjectForKey(NSClassFromString(“NSDictionary”), New UIColor(c), keyStr)
Declare Sub setTitleTextAttributes Lib “UIKit” selector “setTitleTextAttributes:forState:” _
(obj_id As ptr, att As ptr, state As UIControlState)
setTitleTextAttributes(seg.Handle, nsDic, state)
You will then be able to set the Textcolor like this in the Opening event:
me.SetTextColorXC(&c0000FF, SegmentedControlExtensionsXC.UIControlState.Normal)
me.SetTextColorXC(&cFF0000, SegmentedControlExtensionsXC.UIControlState.Selected)
1 Like
Your screenshot suggests the first issue is about quotes, so I’d first try replacing them with real quotes ("). This forum is known to mess them easily.
Sorry about that, the forum messed up the quotes.
Declare Function dlopen Lib "/usr/lib/libSystem.dylib" (path As CString, mode As Integer) As Ptr
Declare Function dlsym Lib "/usr/lib/libSystem.dylib" ( handle As Ptr, name As CString ) As ptr
Dim uikitHandle As Ptr = dlopen("/System/Library/Frameworks/UIKit.framework/UIKit", 2)
Dim symAddr As Ptr = dlsym(uikitHandle, "NSForegroundColorAttributeName")
Dim keyStr As ptr = symAddr.Ptr(0)
Declare Function NSClassFromString Lib "Foundation" (aClassName As CFStringRef) As Ptr
Declare Function dictionaryWithObjectForKey Lib "Foundation" selector "dictionaryWithObject:forKey:" _
(clsRef As ptr, obj As ptr, key As ptr) As ptr
Dim nsDic As ptr = dictionaryWithObjectForKey(NSClassFromString("NSDictionary"), New UIColor(c), keyStr)
Declare Sub setTitleTextAttributes Lib "UIKit" selector "setTitleTextAttributes:forState:" _
(obj_id As ptr, att As ptr, state As UIControlState)
setTitleTextAttributes(seg.Handle, nsDic, state)
1 Like
awesome, works great now


