带有stretchableImageWithLeftCapWidth的UIImageView不会拉伸图像 [英] UIImageView with stretchableImageWithLeftCapWidth doesn't stretch image
问题描述
我正在尝试在UIImageView中拉伸一个图像 - 但我失败了:)
I'm trying to stretch an Image in a UIImageView - but I fail miserably :)
以下设置:
带有视图的NIB-File和附加到此视图的UIImageView。
NIB-File with a view and a UIImageView attached to this view.
使用 IBOutlet UIImageView * background
。
现在,在我的课程中,我尝试以下方法:
Now, in my class I try the following:
UIImage *bgImage = [[UIImage imageNamed:@"myImage.png"] stretchableImageWithLeftCapWidth:0 topCapHeight:50];
[background setImage: bgImage];
bgFrame = CGRectMake(0, 0, 250, 200);
background.frame = bgFrame;
应垂直拉伸图像 - 至少,这就是我的想法。唉,它没有用...... :(
which should stretch the image vertically - at least, that's what I thought. Alas, it's not working... :(
我正在使用的图像高度为115px(这对于拉伸应该足够了,我猜?) / p>
The image I'm using has a height of 115px (which should be enough for the stretch, I guess?)
推荐答案
知道了......(有趣的是,在提问后几秒钟就会发生这种情况)
Got it... (interesting that this happens often just seconds after asking the question)
在IB中,我不得不将UIImageView中的模式设置为«Scale to fill»并设置Autoresize-property
In IB, I had to set the mode in the UIImageView to «Scale to fill» and set the Autoresize-property
这就解决了问题...
That's what solved the problem...
希望能帮到某人;)
这篇关于带有stretchableImageWithLeftCapWidth的UIImageView不会拉伸图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!