iOS Question Line Break to Button

tufanv

Expert
Licensed User
Hello,

I want to make my button 2 lines. I am using line1 & crlf & line2 but line 2 is not visible. How do i do it ?

ty
 

Filippo

Expert
Licensed User
That should work.;)
B4X:
SetMultiline(mybutton)

Public Sub SetMultiline(b As Button)
    Dim no As NativeObject = b
    no.GetField("titleLabel").SetField("numberOfLines", 0)
    no.GetField("titleLabel").SetField("textAlignment", 1)
End Sub
 

tufanv

Expert
Licensed User
That should work.;)
B4X:
SetMultiline(mybutton)

Public Sub SetMultiline(b As Button)
    Dim no As NativeObject = b
    no.GetField("titleLabel").SetField("numberOfLines", 0)
    no.GetField("titleLabel").SetField("textAlignment", 1)
End Sub
Works Excellent! Ty!
 

sdesan

Member
Licensed User
it's my first 'convertion' from b4a in b4i and for button description i have the multiline problem
this is my code
B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'Public variables can be accessed from all modules.
   Public App As Application
   Public NavControl As NavigationController
   Private Main1 As Page
   Private princi As Page
   Private ImageView1 As ImageView
   Dim MyButton As Button
End Sub

Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Main1.Initialize("Main1")
   Main1.Title = "My App 1st page"
   NavControl.NavigationBarVisible = False
   MyButton .Initialize("MyButton ",MyButton .STYLE_SYSTEM)
   SetMultiline(MyButton )
   Main1.RootPanel.LoadLayout("splash")
   NavControl.ShowPage(Main1)
End Sub

Sub ImageView1_Click
  princi.Initialize("princi")
  princi.Title = "My App 2nd page"
  princi.RootPanel.LoadLayout("principal")
  NavControl.ShowPage(princi)
End Sub

Public Sub SetMultiline(b As Button)
  Dim no As NativeObject = b
  no.GetField("titleLabel").SetField("numberOfLines", 0)
End Sub
The button with multiline is on the second page (principal) but i don't view a multiline: what's my error?!?
Thank you
 
Top