Graphic Centring

I am trying to centre some graphics using the following but getting tangled with the syntax. I grabbed the ref example but won’t work

g.TextFont = New iOSFont(“Helvetica Neue”, 60)
Var tls As size
tls = g.TextLineSize(“Game Over”, -1, iOSTextAlignment.Left, False)
var x as double = tls.Width
g.DrawTextLine(“Game Over”, (g.Width-x) \ 2, g.Height \ 2)

Try g.DrawTextLine(“Game Over”, g.Width/2 -x/2, g.Height / 2)

1 Like

Centered horizontally and vertically:

Dim tls As Xojo.Core.size
tls = g.TextLineSize("Game Over", g.Width, iOSTextAlignment.Center, False)
g.DrawTextLine("Game Over", 0, (g.Height-tls.Height)/2+g.TextFont.Ascent, g.Width, iOSTextAlignment.Center)
1 Like