Vinicius Albino
Vinicius Albino

Reputation: 763

Setting TextLabel Position Objective-c

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;

Upvotes: 0

Views: 5127

Answers (2)

Fernando Cervantes
Fernando Cervantes

Reputation: 2962

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);

Upvotes: 0

Oscar Gomez
Oscar Gomez

Reputation: 18488

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.

Upvotes: 2

Related Questions