UILabel setting x,y co-ordinates programmatically UILabel setting x,y co-ordinates programmatically xcode xcode

UILabel setting x,y co-ordinates programmatically


Here you can adjust the position of UILabel.In viewWillAppear method you just need to change the origin of UILabel as below.

     CGRect frame = myLabel.frame;     frame.origin.y=10;//pass the Y cordinate      frame.origin.x= 12;//pass the X cordinate     myLabel.frame= frame;

I hope it clears you.


[label setFrame:CGRectMake(10,20,100,200)];


Instead of setting the frame you can use just setCenter(x, y).

Eg: myLabel.center = CGPointMake(x,y);.

Here you just need to pass the points at where you want to put UIlabel inside the UIView.