-
-
Save j0ris/8038667a374da0f6a24d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *imageName = @"grid.png"; // the image is here: http://f.cl.ly/items/050w3k342y032F0E3n29/grid.png | |
UIImageView *imageView1 = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]] autorelease]; | |
UIImageView *imageView2 = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]] autorelease]; | |
UIImageView *imageView3 = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]] autorelease]; | |
CGSize imageSize; | |
imageSize.width = imageView1.frame.size.width; | |
imageSize.height = imageView1.frame.size.height; | |
CGSize stretchSize; | |
stretchSize.width = 50.0; | |
stretchSize.height = 100.0; | |
imageView1.contentStretch = CGRectMake(0.0, 0.0, stretchSize.width/imageSize.width, stretchSize.height/imageSize.height); | |
imageView2.contentStretch = imageView1.contentStretch; | |
imageView3.contentStretch = CGRectMake(100.0/imageSize.width, 100.0/imageSize.height, stretchSize.width/imageSize.width, stretchSize.height/imageSize.height); | |
// horizonzal stretch | |
imageView1.frame = CGRectMake(10.0, 10.0, imageSize.width*1.2, imageSize.height); | |
// vertical stretch | |
imageView2.frame = CGRectMake(10.0, imageView1.frame.origin.y + imageView1.frame.size.height + 10.0, imageSize.width, imageSize.height*1.2); | |
// middle stretch | |
imageView3.frame = CGRectMake(imageView1.frame.origin.x + imageView1.frame.size.width + 10.0, 10.0, 450.0, 450.0); | |
[self.view addSubview:imageView1]; | |
[self.view addSubview:imageView2]; | |
[self.view addSubview:imageView3]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment