objective-cxcodeiosuiimageviewstretching

How to strech UIImageView (iphone dev.)?


I'm studying Objective-c for several months, so I'm beginner.

I have an image (vertical gradient) 253px x 80px. And I want to stretch it to the screen width.

How can I make UIImageView * 1024( or 768) x 80px with this image?


Solution

  • CGRect myImageRect = CGRectMake(0.0f, 0.0f, self.view.frame.size.width, 80.0f); 
    UIImageView *myImage = [[UIImageView alloc] initWithFrame:myImageRect]; 
    [myImage setImage:[UIImage imageNamed:@"gradient-253x80.png"]]; 
    [self.view addSubview:myImage];