Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert existing height of UIView for iphone 5

Hi I have developed app for iPhone4 now I want to convert the app into iPhone5, I have a UIView named settingsView it is popped up by click of a UIButton. I wanted to know how to adjust the height of the settingsView for iPhone5 .

 -(IBAction)settingsButtonChanged:(UIButton *)sender
{
    UIImageView *settingsImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"settingsViewImage.png"]];
    settingsImage.frame = CGRectMake(25.0, 40.0, 280.0, 370.0);


    settingsView.frame = CGRectMake(0.0, 20.0, 280.0, 370.0);
    settingsView.backgroundColor = [UIColor clearColor];
    [settingsView addSubview:settingsImage];

}
like image 530
rock rocky Avatar asked Dec 04 '25 06:12

rock rocky


1 Answers

If you use the new autolayout system, you can set constraints that will automatically adjust your view's layout to take advantage of the screen size. For example, if you have several elements near the top of the view, a table in the middle, and some buttons near the bottom, you can add constraints that:

  • keep the top elements a fixed distance from the top of the view
  • keep the spacing between top elements fixed
  • keep the bottom buttons a fixed distance from the bottom of the view
  • adjust the table's height so that the table grows on a larger screen and shrinks on a smaller one

You can do the math and make the adjustments yourself, but the whole point of the autolayout system is that you don't have to bother -- let the view do it for you.

like image 65
Caleb Avatar answered Dec 06 '25 22:12

Caleb