如何在我的iOS APP中制作可变的背景图像

问题描述 投票:0回答:2

我正在制作iPhone应用程序,并且我想知道如何将可变背景图像设置为用户可以选择其中一个选项的背景?

iphone xcode uiimage
2个回答
8
投票

我不知道您要在前景中做什么,但是任何基于UIView类的东西都具有backgroundColor属性,您可以将其设置为这样的图像:

yourView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"YourImage.png"]];

0
投票

它对我不起作用,起作用的是:

self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"background.png"]];

我认为是相同的,但不知道为什么其他答案对我不起作用。

希望有帮助。

© www.soinside.com 2019 - 2024. All rights reserved.