mcarrara3
Jul 22, 2014 - 18:53
Hello, how can I create and rotate a label of pi/2? I've already tried the GState() example, but when you input pi/2 the text disappears...
Hello, how can I create and rotate a label of pi/2? I've already tried the GState() example, but when you input pi/2 the text disappears...
Can you post an example of what you tried?
I think I figured it out by myself. Here's the code, in case someone needs it!
# coding: utf-8
import ui
from math import pi
# Preliminary step: create an empty UI and call it myview
# loading view
v = ui.load_view('myview')
# creating label
ylabel = ui.Label()
ylabel.text = 'Hello World'
ylabel.center = (v.width/2., v.height/2.)
#creating a transform object
rot = ui.Transform.rotation(-pi/2)
# applying the transform object to the label
ylabel.transform = rot
# adding the label to the view
v.add_subview(ylabel)
v.present()