iOS Question background image over the whole screen

Wolli013

Active Member
Licensed User
Is it possible to display a background image over the whole screen of B4I, even with a navigation bar?
If so, what do I have to do?

Greetings Wolfgang
 

Brandsum

Well-Known Member
Licensed User
display a background image over the whole screen of B4I, even with a navigation bar?
Your question is not clear.
1. Do you want to show an image over the navigation bar (means the navigation bar will be hidden under the image)?
2. Do you want to show an image under the navigation bar (means the navigation bar will be transparent)?

Which one you want?
 

Wolli013

Active Member
Licensed User
2. Do you want to show an image under the navigation bar (means the navigation bar will be transparent)?
 

Brandsum

Well-Known Member
Licensed User
Add an imageview to the bottom of all view with anchors set to both in your bil file. Then use this code on page resize,

B4X:
Sub Page_Resize (Width As Float, Height As Float)
  
    Dim no As NativeObject = Main.NavControl
    Dim CGRect As Object = no.GetField("navigationBar").GetField("frame").RunMethod("CGRectValue", Null)
    Dim f() As Float = no.ArrayFromRect(CGRect)
  
    no.GetField("navigationBar").SetField("translucent", True)
    no.GetField("navigationBar").RunMethod("setBackgroundColor:", Array(no.ColorToUIColor(Colors.Transparent)))
    no.GetField("navigationBar").RunMethod("setBarTintColor:", Array(no.ColorToUIColor(Colors.Transparent)))
    no.GetField("navigationBar").RunMethod("setTintColor:", Array(no.ColorToUIColor(Colors.white))) 'nav bar text/icon tint color
    Page.RootPanel.Top = 0 - (f(3))
    Page.RootPanel.SizeToFit
    Page.RootPanel.Height = 100%y + (f(3))
  
End Sub
 

Wolli013

Active Member
Licensed User
I just can't get it right.
Maybe you'll point it out.
Enclosed my test code
Because of the file size I could not upload an image file with it.
 

Attachments

Wolli013

Active Member
Licensed User
Works well so far, only when you rotate the screen it doesn't work properly. Do you have a solution?
 

Wolli013

Active Member
Licensed User
If someone knows how to get it done, the following pages will be displayed all over the page. So without TabStrip?
 

Erel

Administrator
Staff member
Licensed User
Try this:
B4X:
Sub Page1_Appear
   Dim no As NativeObject = NavControl
   Dim NaObj2 As NativeObject
   NaObj2 = NaObj2.Initialize("UIImage").RunMethod("new",Array())
   no.GetField("navigationBar").RunMethod("setBackgroundImage:forBarMetrics:",Array(NaObj2,0))
   no.GetField("navigationBar").RunMethod("setShadowImage:",Array(NaObj2))
   no.GetField("view").RunMethod("setBackgroundColor:",Array(no.ColorToUIColor(Colors.Transparent)))
   no.GetField("navigationBar").SetField("translucent", True)
   no.GetField("navigationBar").RunMethod("setBackgroundColor:", Array(no.ColorToUIColor(Colors.Transparent)))
   no.GetField("navigationBar").RunMethod("setBarTintColor:", Array(no.ColorToUIColor(Colors.Transparent)))
   no.GetField("navigationBar").RunMethod("setTintColor:", Array(no.ColorToUIColor(Colors.White))) 'nav bar text/icon tint color
End Sub

Private Sub Page1_Resize(Width As Float, Height As Float)
   Dim no As NativeObject = NavControl
   Dim CGRect As Object = no.GetField("navigationBar").GetField("frame").RunMethod("CGRectValue", Null)
   Dim f() As Float = no.ArrayFromRect(CGRect)
   no = Me
   Page1.RootPanel.Top = 0 - (f(3)) - no.RunMethod("statusBarHeight",Null).AsNumber
   Page1.RootPanel.Height = GetDeviceLayoutValues.Height
End Sub
 

Wolli013

Active Member
Licensed User
@Erel Thank you laüft super.
But how do I get it that the HG image is also displayed over the whole screen on subsequent pages?
 
Top