我决定以不同的方式来解决这个问题,所以我应该回答我自己的问题 - 我希望它可以帮助某人。
我没有允许用户更改每个设置,而是创建了一系列样式 (0-5),存储在 plist 中(除其他外)。
每种样式都有一组变量(字体名称、大小、颜色等)。
设置文件使用如下所示的变量,并在应用程序启动时读取:
AppDelegate *mainDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
styleKeyValue = [mainDelegate styleValueKey];
styleKey = [styleKeyValue intValue];
switch (styleKey) {
case 0:
fontName = @"Arial";
fontSize = 16;
selectedTintColor = [UIColor blackColor];
selectedFontColor = [UIColor blackColor];
backgroundImage = @"background0.png";
break;
case 1:
fontName = @"Times";
fontSize = 14;
selectedTintColor = [UIColor blueColor];
selectedFontColor = [UIColor blackColor];
backgroundImage = @"background1.png";
break;
case 5:
...
}
selectedTintColor 和 selectedFontColor 定义为:
UIColor *selectedTintColor;
UIColor *selectedFontColor;
fontName 和 backgroundImage 被定义为 NSStrings。字体大小是本地整数。
当我想给一个单元格设置样式时,我只需要输入这个:
cell.textLabel.font = [UIFont fontWithName:fontName size:fontSize];
cell.textLabel.textColor = selectedFontColor;
(tintColor 用于设置分段单元格的样式。)
再次,我希望这可以帮助某人。我花了一整夜才找到这个相当简单的解决方案..