在我的应用程序中,整个 UI 都是基于 tintColor 的,我让用户有机会自己选择一种颜色,然后我将其保存在NSUserDefaults
这是我的 AppDelegate 的代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if (![[NSUserDefaults standardUserDefaults] objectForKey:@"ThemeColor"])
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSData *colorData = [NSKeyedArchiver archivedDataWithRootObject: [UIColor orangeColor]];
[defaults setObject: colorData forKey:@"ThemeColor"];
[defaults synchronize];
self.window.tintColor = [UIColor orangeColor];
}
else
{
NSData *colorData = [[NSUserDefaults standardUserDefaults] objectForKey:@"ThemeColor"];
UIColor *color = [NSKeyedUnarchiver unarchiveObjectWithData:colorData];
self.window.tintColor = color;
}
return YES;
}
我让用户在 UITableView 中更改颜色,那么我如何从 didSelectRowAtIndex 重新加载上面的代码(或类似的代码)?