iOS Question Image and text on B4XSwiftButton

tsteward

Well-Known Member
Licensed User
Longtime User
In B4A I do the following but how do I do the same in B4I please?
Dim cs As CSBuilder
cs.Initialize
cs.Initialize.color(Colors.White).Size(20).Typeface(Typeface.FONTAWESOME).VerticalAlign(1dip).Append(Chr(0xF1EC)).Pop. _
Typeface(Typeface.DEFAULT_BOLD).Append(CRLF).Size(14).Append("Hex 2 Dec").PopAll
SwiftBtnCalc.xLBL.Text = cs
 

tsteward

Well-Known Member
Licensed User
Longtime User
Sorry I did try but couldn't find the code button.

It sort of works.
Do I need separate code for B4A and B4I as typeface not available in B4I and Font not available in B4A
I'm trying to have the icon above the text, commented out code works perfectly in B4A

My Code
B4X:
    LoadDrawer
'    #if b4a
'    Dim cs As CSBuilder
'    cs.Initialize
'    cs.Initialize.color(Colors.White).Size(20).Typeface(Typeface.FONTAWESOME).VerticalAlign(1dip).Append(Chr(0xF1EC)).Pop. _
'    Typeface(Typeface.DEFAULT_BOLD).Append(CRLF).Size(14).Append("Hex 2 Dec").PopAll
'    SwiftBtnCalc.xLBL.Text = cs
'    #end if
    
    Dim cs As CSBuilder
    cs.Initialize.Color(Colors.White).Font(Font.CreateFontAwesome(20)).VerticalAlign(-10).Append(Chr(0xF1EC)).Pop. _
    Font(Font.DEFAULT).Append(CRLF).Append("Hex").PopAll
    XUIViewsUtils.SetTextOrCSBuilderToLabel(SwiftBtnCalc.xLBL, cs)
 
Upvote 0

tsteward

Well-Known Member
Licensed User
Longtime User
I don't know how to correct this.
B4X:
Dim cs As CSBuilder
    cs.Initialize
    #if b4a
    cs.Initialize.color(Colors.White).Size(20).Typeface(Typeface.FONTAWESOME).VerticalAlign(1dip).Append(Chr(0xF1EC)).Pop. _
    Typeface(Typeface.DEFAULT_BOLD).Append(CRLF).Size(14).Append("Calculators").PopAll
    SwiftBtnCalc.xLBL.Text = cs
    #else if B4I
    cs.Initialize.Color(Colors.White).Font(Font.CreateFontAwesome(20)).VerticalAlign(1dip).Append(Chr(0xF1EC)).Pop. _
    Font(Font.DEFAULT).Append(CRLF).Append("Hex").PopAll
    XUIViewsUtils.SetTextOrCSBuilderToLabel(SwiftBtnCalc.xLBL, cs)
    #end if
So the B4A code creates this button
Screenshot_20220101-151623.jpg

The B4I creates this button
20220101_151809.jpg
 
Upvote 0

tsteward

Well-Known Member
Licensed User
Longtime User
114 views but no solution....
Please is this not doable? or am I not giving enough information?
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
test:
B4X:
SwiftBtnCalc.xLBL.As(Label).SizeToFit

B4X:
    Dim cs As CSBuilder
    #if b4a
    cs.Initialize.Alignment("ALIGN_CENTER").color(Colors.White).Size(20).Typeface(Typeface.FONTAWESOME).VerticalAlign(1dip).Append(Chr(0xF1EC)).Pop. _
    Typeface(Typeface.DEFAULT_BOLD).Append(CRLF).Size(14).Append("Calculators").PopAll
    XUIViewsUtils.SetTextOrCSBuilderToLabel(SwiftBtnCalc.xLBL, cs)
    #else if B4I
    cs.Initialize.Alignment("ALIGN_CENTER").Color(Colors.White).Font(Font.CreateFontAwesome(20)).VerticalAlign(1dip).Append(Chr(0xF1EC)).Pop. _
    Font(Font.DEFAULT).Append(CRLF).Append("Hex").PopAll
    XUIViewsUtils.SetTextOrCSBuilderToLabel(SwiftBtnCalc.xLBL, cs)
    SwiftBtnCalc.xLBL.As(Label).SizeToFit
    #end if
 
Last edited:
Upvote 0

tsteward

Well-Known Member
Licensed User
Longtime User
Unfortunately no change :(
 
Upvote 0

tsteward

Well-Known Member
Licensed User
Longtime User
Thank you I tried that. Also tried selecting multi line in the designer.
I have made the button huge
It just will not display a second line in Ios
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
if you have multiline set to true

update Swiftbutton:
B4X:
    Dim cs As CSBuilder
    #if b4a
    cs.Initialize.Alignment("ALIGN_CENTER").color(Colors.White).Size(20).Typeface(Typeface.FONTAWESOME).VerticalAlign(1dip).Append(Chr(0xF1EC)).Pop. _
    Typeface(Typeface.DEFAULT_BOLD).Append(CRLF).Size(14).Append("Calculators").PopAll
    XUIViewsUtils.SetTextOrCSBuilderToLabel(SwiftBtnCalc.xLBL, cs)
    #else if B4I
    cs.Initialize.Alignment("ALIGN_CENTER").Color(Colors.White).Font(Font.CreateFontAwesome(20)).VerticalAlign(1dip).Append(Chr(0xF1EC)).Pop. _
    Font(Font.DEFAULT).Append(CRLF).Append("Hex").PopAll
    XUIViewsUtils.SetTextOrCSBuilderToLabel(SwiftBtnCalc.xLBL, cs)
    #end if
    SwiftBtnCalc.Update
 
Upvote 0

tsteward

Well-Known Member
Licensed User
Longtime User
I’m sorry to waste your time and do appreciate your help but no change
 

Attachments

  • 4F6E4C24-CD91-41D1-A02A-D1ADFD928BBB.png
    4F6E4C24-CD91-41D1-A02A-D1ADFD928BBB.png
    398.4 KB · Views: 108
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
test (pop)
B4X:
    Dim cs As CSBuilder
   
    #If B4A
    cs.Initialize
    cs.Alignment("ALIGN_CENTER")
    cs.Color(Colors.White)
    cs.Size(20)
    cs.Typeface(Typeface.FONTAWESOME)
    cs.Append(Chr(0xF1EC))
'    cs.Pop
    cs.Append(CRLF)
    cs.Typeface(Typeface.DEFAULT_BOLD)
    cs.Size(14)
    cs.VerticalAlign(1dip)
    cs.Append("Calculators")
    cs.PopAll
   
    SwiftBtnCalc.xLBL.As(Label).SingleLine = False
    #Else If B4I
   
    cs.Initialize
    cs.Alignment("ALIGN_CENTER")
    cs.Color(Colors.White)
    cs.Font(Font.CreateFontAwesome(20))
    cs.Append(Chr(0xF1EC))
'    cs.Pop
    cs.Append(CRLF)
    cs.Font(Font.DEFAULT_BOLD)
    cs.Font(Font.CreateNew(14))
    cs.VerticalAlign(1dip)
    cs.Append("Calculators")
    cs.PopAll
   
    SwiftBtnCalc.xLBL.As(Label).Multiline = True
    #End If

    XUIViewsUtils.SetTextOrCSBuilderToLabel(SwiftBtnCalc.xLBL, cs)
    SwiftBtnCalc.Update
 
Last edited:
Upvote 0
Top