Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 使用[UIImageView StretcableImageWithLeftCapWidth:topCapHeight:]时出现问题_Iphone_Uikit - Fatal编程技术网

Iphone 使用[UIImageView StretcableImageWithLeftCapWidth:topCapHeight:]时出现问题

Iphone 使用[UIImageView StretcableImageWithLeftCapWidth:topCapHeight:]时出现问题,iphone,uikit,Iphone,Uikit,我使用这种方法是为了避免图像拉伸。这就是它的用途。 [aImgView setImage:[[UIImage imageNamed:@“dummy.png”]可拉伸图像与leftcapwidth:0.0 topCapHeight:30.0] 但图像仍在拉伸以填充整个帧。在使用之前是否需要设置任何属性,或者此处是否遗漏了某些内容?任何澄清都很有帮助。请在代码中使用这一行: aImgView.contentMode = UIViewContentModeScaleAspectFit; 我理解你的问

我使用这种方法是为了避免图像拉伸。这就是它的用途。
[aImgView setImage:[[UIImage imageNamed:@“dummy.png”]可拉伸图像与leftcapwidth:0.0 topCapHeight:30.0]


但图像仍在拉伸以填充整个帧。在使用之前是否需要设置任何属性,或者此处是否遗漏了某些内容?任何澄清都很有帮助。

请在代码中使用这一行:

aImgView.contentMode = UIViewContentModeScaleAspectFit;

我理解你的问题,就好像你希望前30个像素保持不拉伸,而你希望图片的其余部分拉伸一样

我从来没有用LeftCapWidth获得过在iOS上工作的拉伸图像。但是,以下方法非常有效:

[aImgView setImage:[[UIImage imageNamed:@"dummy.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(30, 0, 30, 0) resizingMode:UIImageResizingModeStretch]];
您肯定会想将其设置为

aImgView.contentMode = UIViewContentModeScaleToFill;

否则,整个按钮将在考虑方面的情况下拉伸

aImgView.contentMode=UIViewContentModeScaleToFill,不是吗?@KrisJenkins请详细说明。