Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
View.center not the center?
-
I am working with the UI module, and I came across an issue where view.center wasn't giving me the center of the view. Some created my own function for getting the center of the view as a tuple.
They return different values.
<pre>
def Get_Center(frame):
center = (frame.width/2,frame.height/2)
return centerprint customView.center
print Get_Center(customView)
</pre>
My function made the UI control go to the center.
Any ideas what is happening? -
center
doesn't tell you where the center of your view is in its own coords, it tells you the center in the containing views coords, just likeframe
, andx
andy
. If your view's x and y attributes happen to be 0, then you'll get the same answer (assuming you have not used transform to rotate the view, or are doing funny things with bounds)So, you use
center
for positioning a view, not for positioning its subviews.