开发者

Setting TextLabel Position Objective-c

开发者 https://www.devze.com 2023-04-12 07:31 出处:网络
I have a Scroll View with many objects in it,since i cant edit the position on scrollview in InterfaceBuilder,how i set the position of the object programmactily?

I have a Scroll View with many objects in it,since i cant edit the position on scrollview in InterfaceBuilder,how i set the position of the object programmactily? Something like:

myTextField.x = 50;
myTextField.y开发者_StackOverflow中文版 = 540;


Use the frame property to set it relative to the superview's coordinates like this:

myTextLabel.frame = CGRectMake(x, y, width, height);

There is no textlabel but I assume you mean either UITextField or UILabel, either way both inherit from UIView and have the frame property.


You could also move it according to the object's center.

float x = 220; //Change This Number
float y = 180; //Change This Number

myTextField.center = CGPointMake(x,y);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号