How to set a image as the background of UIView but scaled properly?
<p>I would like the user to be able to select a image from their photos and set it to the background of the main view. </p>

<p>This is what I'm currently doing: </p>

<pre><code>- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [picker dismissModalViewControllerAnimated:YES];

    UIImage *testimg = [info objectForKey:UIImagePickerControllerOriginalImage];

    NSArray  * sysPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES );

    filePath = [[NSString alloc] initWithFormat: @"%@/%@", [sysPaths objectAtIndex: 0], @"testimg.png"];
    if ( [UIImagePNGRepresentation ( testimg) writeToFile:filePath atomically:YES] )    ;

    self.backgroundColor= [[UIColor alloc] initWithPatternImage:[[UIImage alloc] initWithContentsOfFile: filePath]];


     }
</code></pre>

<p>Aside from this method being a bit sluggish in speed, this works great! There is one problem though. When the image is selected the image is not scaled properly. How would I get around this?</p>

<p>Thanks in advance,</p>

<p>-David</p>
