【发布时间】:2012-11-12 16:06:33
【问题描述】:
我有 UIImageView 在 View 中具有背景图像的作用。我想在此 UIImageView 中加载两个不同的图像,具体取决于在 Settings Bundle 中的切换开关中选择的状态。
最好的方法是什么?
【问题讨论】:
标签: objective-c xcode ios6 settings.bundle
我有 UIImageView 在 View 中具有背景图像的作用。我想在此 UIImageView 中加载两个不同的图像,具体取决于在 Settings Bundle 中的切换开关中选择的状态。
最好的方法是什么?
【问题讨论】:
标签: objective-c xcode ios6 settings.bundle
试试这样的:
NSUserDefaults* settings = [NSUserDefaults standardUserDefaults];
NSString* imgName = [settings boolForKey:@"toggle_switch"] ? @"switch_on.png" : @"switch_off.png";
UIImage* img = [UIImage imageNamed:imgName];
[imageView setImage:img];
【讨论】: