Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing CGRectMake (x,x,x,x) to a different location such as (y,y,y,y)

I have placed a button in my view using CGRectMake(x,x,x,x), x being the location and size of course. When I rotate the view using -(BOOL)shouldAutoRotate... I want to change the location of the button from what would be the center in portrait mode to the center in landscape mode. The button contains information in its label that the user sets, so I DON'T want to use a different view for the landscape orientation. What if they set something in portrait and rotate to horizontal? They'll lose their data. So my question is: how do I move something that was previously set? See the code below, I don't want to realloc the button. Thanks!

// DATE

lblDate = [[UILabel  alloc] initWithFrame:CGRectMake(x, y, width, height)];

lblDate.text = @"Date:";
lblDate.backgroundColor = [UIColor clearColor];
[contentView addSubview:lblDate];
like image 364
Jack Humphries Avatar asked Jul 08 '11 18:07

Jack Humphries


1 Answers

Just set the frame equal to a new Rect, e.g.

lblDate.frame = CGRectMake(x,y,width,height);
like image 152
George Johnston Avatar answered Oct 04 '22 21:10

George Johnston