0

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 = 540;
Jamie Hutton
  • 260
  • 3
  • 13
Vinicius Albino
  • 743
  • 2
  • 8
  • 21

2 Answers2

2

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.

Oscar Gomez
  • 18,436
  • 13
  • 85
  • 118
0

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);
Fernando Cervantes
  • 2,962
  • 2
  • 23
  • 34