1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

iOS Question background image over the whole screen

Discussion in 'iOS Questions' started by Wolli013, Jul 27, 2019.

  1. Wolli013

    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
     
  2. Brandsum

    Brandsum Active Member Licensed User

    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?
     
  3. Wolli013

    Wolli013 Active Member Licensed User

    2. Do you want to show an image under the navigation bar (means the navigation bar will be transparent)?
     
  4. Brandsum

    Brandsum Active 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,

    Code:
    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
     
    Erel and Wolli013 like this.
  5. Wolli013

    Wolli013 Active Member Licensed User

    Thank You
     
  6. Wolli013

    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.
     

    Attached Files:

  7. Brandsum

    Brandsum Active Member Licensed User

    There was a problem in my last post. Check this corrected project
     

    Attached Files:

    Erel and Wolli013 like this.
  8. Wolli013

    Wolli013 Active Member Licensed User

    Thank you, now it's on.
     
    Last edited: Jul 29, 2019
  9. Wolli013

    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?
     
  10. Wolli013

    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?
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    Try this:
    Code:
    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 likes this.
  12. Wolli013

    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?
     
  13. Erel

    Erel Administrator Staff Member Licensed User

    You will need to do a similar thing in all the pages.
     
    Wolli013 likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice