Created
August 28, 2013 13:58
-
-
Save zhangwc/6366344 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 是否高清屏 | |
#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