I got something working for setting the navigation bar proxy background colour so all views navigation bars are created with the colour I set. I’m able to call this once in the app open event and it seems to work well. Here is the code I am using. I don’t know if there is a better way so any comments on how to improve would be welcome.
[code] Declare Function NSClassFromString Lib “Foundation” (classname As CFStringRef) As Ptr
// Create pointer to UINavigationBar
Dim navBarPtr As Ptr = NSClassFromString(“UINavigationBar”)
// Get a proxy to the class
Declare Function GetAppearanceProxy lib “UIKit” selector “appearance” (UINavigationBar As Ptr) As Ptr
Dim navBarProxy As Ptr = GetAppearanceProxy(navBarPtr)
// Create the colour
Dim theUIColorClassRef As Ptr = NSClassFromString(“UIColor”)
Declare Function GetColorWithRGBA lib “UIKit” selector “colorWithRed:green:blue:alpha:” (UIColorClassRef As Ptr, red As Single, green As Single, blue As Single, alpha As Single) As Ptr
Dim myUIColorObject As ptr = GetColorWithRGBA(theUIColorClassRef, (139.0/255.0), (172.0/255.0), (165.0/255.0), 1.0)
Declare Sub SetDefaultColour lib “UIKit” selector “setBarTintColor:” (UINavigationBar As Ptr, myNavBarBackgroundColor As Ptr)
SetDefaultColour(navBarProxy, myUIColorObject)
[/code]
I wanted to add code to set up the background colour for all table cell views. I thought I could do the same as above but it is not working. Here is the code I added.
[code] // Create pointer to view
Dim viewPtr As Ptr = NSClassFromString(“UIView”)
// Get a proxy to the class
Declare Function GetAppearanceProxy2 lib “UIKit” selector “appearance” (UIView As Ptr) As Ptr
Dim viewProxy As Ptr = GetAppearanceProxy2(viewPtr)
// Create the colour
myUIColorObject = GetColorWithRGBA(theUIColorClassRef, (213.0/255.0), (223.0/255.0), (229.0/255.0), 1.0)
Declare Sub SetDefaultColour2 lib “UIKit” selector “setBackgroundColor:” (UIView As Ptr, myBackgroundColor As Ptr)
SetDefaultColour2(viewProxy, myUIColorObject)
[/code]
This added code sets the colour on the whole screen and covers over everything. So you can’t see the title, any rows, etc. I tried changing the code to “setTintColor:” instead, but that didn’t do anything.
Is there a way to set the table cells proxy so the tables have the background colour I want?