我想为我的应用程序设置一个随机背景图像,这样每次有人启动应用程序时都会显示一个新的背景图像。
这是我迄今为止在该- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
方法中尝试过的内容:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSMutableArray *myImageNames = [NSMutableArray arrayWithObjects:@"image1.png", @"image2.png", @"image3.png", nil];
int index = arc4random() % [myImageNames count];
UIColor *background = [[UIColor alloc] initWithPatternImage:[myImageNames objectAtIndex:index]];
self.window.backgroundColor = background;
}
我没有错误,但我不工作......有什么想法吗?:)