I was able to set the NavigationBar color using the code from another thread here.
But I’m struggling to use a picture as NavigationBar Title.
[code]Public Sub setNavBarTitleImage(extends v as iOSView, image As iOSImage)
declare function navigationController lib “UIKit” selector “navigationController” (viewController as ptr) as ptr
declare function navigationBar lib “UIKit” selector “navigationBar” (obj_ref as ptr) as ptr
declare function topItem lib UIKitLib selector “topItem” (id as ptr) as ptr
declare sub setTitleView lib UIKitLib selector “setTitleView:” (id as ptr, UIImage as Ptr)
dim navigationControllerRef as ptr = navigationController(v.ViewControllerHandle)
dim navBar as ptr = navigationBar(navigationControllerRef)
dim navItem as ptr = topItem(navBar)
//Code crashes here, although navItem isn’t &h0000000 in the debugger
setTitleView(navItem, image.Handle)
you have to add before the last instruction :
declare Function NSClassFromString lib “Foundation”(className as CFStringRef) as Ptr
declare Function alloc lib “Foundation” selector “alloc”(classPtr as Ptr) as Ptr
declare Function initWithImage lib “UIKit” selector “initWithImage:”(objRef as Ptr, imgRef as Ptr) as Ptr
dim iView as Ptr= initWithImage( alloc( NSClassFromString(“UIImageView”)), image.Handle)
and then call the setTitleView with the right item
setTitleView(navItem, iView)
[code]Public Sub setNavBarTitleImage(extends v as iOSView, image As iOSImage)
declare function navigationController lib “UIKit” selector “navigationController” (viewController as ptr) as ptr
declare function navigationBar lib “UIKit” selector “navigationBar” (obj_ref as ptr) as ptr
declare function topItem lib UIKitLib selector “topItem” (id as ptr) as ptr
declare sub setTitleView lib UIKitLib selector “setTitleView:” (id as ptr, UIImage as Ptr)
declare Function alloc lib “Foundation” selector “alloc”(classPtr as Ptr) as Ptr
declare Function initWithImage lib “UIKit” selector “initWithImage:”(objRef as Ptr, imgRef as Ptr) as Ptr
//Reference to Navigation Controller
dim navigationControllerRef as ptr = navigationController(v.ViewControllerHandle)
//Ref to NavigationBar
dim navBar as ptr = navigationBar(navigationControllerRef)
//Ref to Title item
dim navItem as ptr = topItem(navBar)
//Create imageView with the passed image
dim iView as Ptr = initWithImage( alloc( NSClassFromString(“UIImageView”)), image.Handle)
//Set Title item to use the imageView
setTitleView(navItem, iView)
End Sub
[/code]