Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.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 将图像组合成一个UIButton?_Iphone_Objective C_Ios_Uiimageview_Uibutton - Fatal编程技术网

Iphone 将图像组合成一个UIButton?

Iphone 将图像组合成一个UIButton?,iphone,objective-c,ios,uiimageview,uibutton,Iphone,Objective C,Ios,Uiimageview,Uibutton,如果我有一个png,它基本上是一个没有任何内容的按钮图像: ---------------- | | ---------------- 我如何在上面放置图像,使图像成为按钮的一部分,如: ---------------- | (image) | ---------------- (我可以在顶部放置一个UIImageView,但它不会继承按钮属性,比如按下时变暗)使用基本上是按钮的图像作为UIButton的背景图像,并使用另一个图像作为UIButton的图像

如果我有一个png,它基本上是一个没有任何内容的按钮图像:

----------------
|              |
----------------
我如何在上面放置图像,使图像成为按钮的一部分,如:

----------------
|    (image)   |
----------------

(我可以在顶部放置一个UIImageView,但它不会继承按钮属性,比如按下时变暗)

使用基本上是按钮的图像作为UIButton的背景图像,并使用另一个图像作为UIButton的图像

[button setImage:[UIImage imageNamed:@"Foo"] forState:UIControlStateNormal];
[button setBackgroundImage:[UIImage imageNamed:@"Bar"] forState:UIControlStateNormal];

使用基本上是按钮的图像作为UIButton的背景图像,并使用其他图像作为UIButton的图像

[button setImage:[UIImage imageNamed:@"Foo"] forState:UIControlStateNormal];
[button setBackgroundImage:[UIImage imageNamed:@"Bar"] forState:UIControlStateNormal];