Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有 UIImageView 在 View 中具有背景图像的作用。我想在此 UIImageView 中加载两个不同的图像,具体取决于在 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];