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 选择或单击按钮时如何显示图像背景_Iphone - Fatal编程技术网

Iphone 选择或单击按钮时如何显示图像背景

Iphone 选择或单击按钮时如何显示图像背景,iphone,Iphone,我在点击按钮时显示选择图像的按钮点击中有此代码 UIImage *img1 = [UIImage imageNamed:@"settingpress.png"]; [_btnclick setImage:img1 forState:(UIControlStateHighlighted+UIControlStateSelected)]; [img1 release]; 但是我没有得到图像,我的按钮是xib中的UIButton,带有自定义

我在点击按钮时显示选择图像的按钮点击中有此代码

 UIImage *img1 = [UIImage  imageNamed:@"settingpress.png"];

             [_btnclick setImage:img1 forState:(UIControlStateHighlighted+UIControlStateSelected)];

             [img1 release];
但是我没有得到图像,我的按钮是xib中的UIButton,带有自定义按钮而不是Roundrect。我的代码中有什么错误。
提前感谢。

您必须使用背景图像和|分隔符:

[_btnclick setBAckgroundImage:img1 forState:(UIControlStateHighlighted|UIControlStateSelected)];

使用自定义样式的按钮(而不是RoundRect)。另外,使用以下方法:-setBackgroundImage:forState:首先检查图像名称是否正确,并尝试在imageview中显示它。如果有效,请使用此代码检查[_btn单击setBackgroundImage:img1 forState:uicontrol状态高亮显示];