iOS Question B4X Drawer Menu - iOS Colour Customisation

RichardN

Well-Known Member
Licensed User
Longtime User
I am just starting out on a new iOS project that requires colour customisation of the interface. The front-end is based on the B4X Drawer Sliding Menu example HERE.

The colour scheme requires on 'old/historic' look and so far all the elements have been easy to change. I am however stuck on the colour of the hamburger graphic. The hamburger.png asset is simply three white bars on a transparent background so the actual colour is being generated by the OS. I suspect I need to do it through a NativeObject method but I can find no reference to it on the forum.

How do you change the hamburger colour in the B4X Drawer?
 

Semen Matusovskiy

Well-Known Member
Licensed User
Open 'Main' module and do following

1) Replace bb.InitializeBitmap(LoadBitmapResize(File.DirAssets, "hamburger.png", 32dip, 32dip, True), "hamburger") to, for example
B4X:
bb = subCreateIconicBarButton (False, 0xE5D2, Colors.Blue, Colors.Red, 32, "hamburger")
Exactly here you can change colors.

2) Replace Page1_BarButtonClick subroutine to
B4X:
Private Sub subCreateIconicBarButton (booleanUseFontAwesome As Boolean, intCode As Int, intTextColorNormal As Int, intTextColorHighLighted As Int, floatFontSize As Float, objectTag As Object) As BarButton

    Dim barbuttonInstance                                                       As BarButton
    Dim buttonInstance                                                          As Button

    buttonInstance.InitializeCustom ("barButton", intTextColorNormal, intTextColorHighLighted)
    If booleanUseFontAwesome Then buttonInstance.CustomLabel.Font = Font.CreateFontAwesome (floatFontSize) Else buttonInstance.CustomLabel.Font = Font.CreateMaterialIcons (floatFontSize)
    buttonInstance.Text = Chr (intCode)
    buttonInstance.Tag  = objectTag
    buttonInstance.SetLayoutAnimated (0, 1, 0, 0, floatFontSize, floatFontSize)
    barbuttonInstance.InitializeCustom (buttonInstance)
    Return barbuttonInstance

End Sub

Private Sub barButton_Click
   
    Dim b As Button = Sender
   
    If b.Tag = "hamburger" Then
        Drawer.LeftOpen = Not(Drawer.LeftOpen)
    End If
End Sub

3) You can remove hamburger.png as not needed.
 
Upvote 0
Top