在UIImageView中更改3张图片

时间:2011-02-01 20:58:44

标签: iphone objective-c background uiimageview

嘿,我想知道如何让用户能够更改应用的背景?我有3个图像,用户可以选择。我在许多应用程序中看到过它。我该怎么做?如果可能请提供一些代码! :)

提前谢谢!

2 个答案:

答案 0 :(得分:0)

问题应该更清楚。

您可以使用

更改UIView或父UIWindow的背景
  view/window.backgroundColor = [UIColor colorWithPatternImage: image]

或使用UIImageView,

  imageView.image = image

答案 1 :(得分:0)

这很容易。您只需将视图的背景属性设置为图像即可。以下是它的完成方式:

self.view.backgroundColor = [UIColor colorWithPatternImage:
                                  [UIImage imageNamed:@"yourimage.png"]];

现在,当用户选择不同的图像时,只需每次使用不同的图像重复上述代码。