iOS Question Page.TopLeftButtons Image Size

Gijsen

Member
Licensed User
Longtime User
I'm adding buttons instead of the hidden back button to allow the user to do specific actions.
To add a custom button on the top left corner of the application I use this code:

Dim bbBack As BarButton
bbBack.InitializeBitmap(LoadBitmap(File.DirAssets, "arrow.png"), "info")
bbBack.TintColor = Colors.White
InfoPage.TopLeftButtons = Array(bbBack)


The button shows, the tag is passed to the InfoPage_BarButtonClick etc. All fine.

Except that I can't find how to control the size of that button.
LoadBitmapSample in B4A would allow me to control the size of the image.

How can I control the size of the button except for resizing the used image itself ?
 

JanPRO

Well-Known Member
Licensed User
Longtime User
Use a ImageView and the InitializeCustom method:

B4X:
Page1.TopLeftButtons = Array(ImageBarButton(LoadBitmap(File.DirAssets,"Test.png"),20,20,"BarButton1"))

Sub ImageBarButton(Image As Bitmap, Height As Float, Width As Float, EventName As String) As BarButton

    Dim IV As ImageView
    IV.Initialize(EventName)
    IV.ContentMode = IV.MODE_FIT
    IV.Bitmap = Image
    IV.Height = Height
    IV.Width = Width

    Dim BB As BarButton
    BB.InitializeCustom(IV)

    Return BB
End Sub

Instead of the BarButtonClick event use now the EventName_Click event ;)
 
Upvote 0
Top