Skip to content

Instantly share code, notes, and snippets.

@zhangwc
Created August 28, 2013 13:58
Show Gist options
  • Save zhangwc/6366344 to your computer and use it in GitHub Desktop.
Save zhangwc/6366344 to your computer and use it in GitHub Desktop.
// 是否高清屏
#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
// 是否iPad
#define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
// 是否模拟器
#define isSimulator (NSNotFound != [[[UIDevice currentDevice] model] rangeOfString:@"Simulator"].location)
// 是否iPhone5
#define iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
// 自由切换语言
#define AppLanguage @"appLanguage"
#define CustomLocalizedString(key, comment) \
[[NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] objectForKey:@"appLanguage"]] ofType:@"lproj"]] localizedStringForKey:(key) value:@"" table:nil]
用法:
if (![[NSUserDefaults standardUserDefaults]objectForKey:AppLanguage]) {
[[NSUserDefaults standardUserDefaults] setObject:@"zh-Hans" forKey:AppLanguage];
}
label.text= CustomLocalizedString(@"sub_menu_download", nil);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment