Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • arranging the images at the center of the iPhone screen

    • 0
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 184
    Comment on it

    It might be required to display a large number of images having different sizes, one by one on the screen. To make it look neat, all the images should be aligned at the center of the screen, irrespective of their size. So fixing the coordinates of the frame of the image view will not do the job. So here's the code to make sure that the images align themselves at the center of the screen, no matter if the size is big or small.

    UIImageView *myImageView = [UIImageView alloc]init];
    UIImage *dispImage = [UIImage imageNamed:[imageArray objectAtIndex:i]];
    float w = dispImage.size.width;
    float h = dispImage.size.height;
    
    [myImageView setImage:[UIImage imageNamed:[muArray objectAtIndex:0]]];
    [myImageView setFrame:CGRectMake((320-w)/2,50,w,h)];
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: