ReasyEasyPeasy ReasyEasyPeasy - 1 year ago 144
Swift Question

change local coordinates of an object(swift3)

I draw a custom UIbutton. Now I want, that the 0,0-point is in the middle of the object. Not on top-left-corner. So If I set the position of this button in a view to the middle point of the view, the button is really in the middle and I dont have to add the half of the width and the half of the height.


If I set the position of the object to the middle of a view it should look this:
right position
and not like this:
false position

Answer Source

You're modifying the origin of the frame, each view has a property center which does exactly what you want.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download