Reputation: 854
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?
Upvotes: 0
Views: 3895
Reputation: 1
One solution would be to call:
imageView.transform = CGAffineTransformMakeScale( 1.5, 1);
This will stretch the image by a factor of 1.5 on the x axis, but retain y axis dimensions.
Upvotes: 0
Reputation: 55
You should use:
Portrait Mode
yourImage.frame = CGRectMake (x start, y start, x width, y width);
Upvotes: 0
Reputation: 9544
You can also look up the documentation on UIImage's method:
- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight
This allows you to make images that can adapt a single small graphic to a variety of sizes and roles. @Chugaister's suggestion.
Upvotes: 0
Reputation: 63707
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];
Upvotes: 1
Reputation: 364
A flag used to determine how a view lays out its content when its bounds change. @property(nonatomic) UIViewContentMode contentMode
UIViewContentModeScaleAspectFit
Upvotes: 3