I’m new to XCode/iOS and I’m trying to figure out how to move a Label based on the left (or right) side, not the center.
All I can find is something like this:
[myLabel setCenter:CGPointMake(x,y)];
I’ve also seen this variant:
myLabel.center=CGPointMake(x,y);
My question has two parts:
-
How do do something similar, but without using the label center?
-
Is “.center” a property of the
UILabelobject? For example, in MS/VB/C#/etc. objects have “.left, .right, .top, .bottom” for positioning – is there something similar in iOS/Objective-C?
centeris a property of UIView, and no, there’s no equivalentleft,right, or whatever. You need to do the calculation manually: the label’s left side islabel.frame.origin.xand its right side islabel.frame.origin.x + label.frame.size.width. If you want to move the label so it’s right-aligned with a particular coordinate, then you can do something like this: