首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏每日一篇技术文章

    Foundation-NSLocale

    String{ let bundlePath = Bundle.main.path(forResource: bundleName, ofType: "bundle") var language = NSLocale.preferredLanguages.count NSLocale.preferredLanguages[0] : "en" let bundle = Bundle(path: bundlePath!)! if !

    39610发布于 2018-09-14
  • 来自专栏iOS逆向与安全

    iOS小技能:本地化(Internationalization & Localization)

    NSLocale实例包含了针对这个地区内特定一群人的所有语言文化基准,其中包括: 语言 键盘 数字、日期和时间格式 货币 排序和分类 符号、颜色与头像的使用 每一个NSLocale实例对应着一个_地区标识符 NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:localeIdentifier];//zh_CN en_US NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:localeIdentifier];//zh_CN en_US *locale = [NSLocale localeWithLocaleIdentifier:@"zh"]; [datePicker setLocale:locale];//本地化 文章:https://blog.csdn.net/z929118967/article/details/104300695 2.2 选择相应的本地化资源 NSLocale +preferredLanguages

    4K30编辑于 2022-08-22
  • 来自专栏猿人谷

    处理日期时间NSDate

    NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"yyyy-MM-DD HH:mm:ss"]; NSLocale *local = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; [df setLocale:local]; NSString NSDateFormatter *df = [[NSDateFormatter alloc] init]; [df setDateFormat:@"yyyy-MM-DD HH:mm:ss"]; NSLocale *local = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; [df setLocale:local]; NSString

    86650发布于 2018-01-17
  • 来自专栏云原生布道专栏

    IOS开发系列——设备信息专题【整理,部分原创】

    那么通过那些api可以获取这些信息呢,iOS的SDK中提供了UIDevice,NSBundle,NSLocaleNSLocale可以获取用户的本地化信息设置,例如货币类型,国家,语言,数字,日期格式的格式化,提供正确的地理位置显示等等。 //Getting the User’s Language NSArray *languageArray = [NSLocale preferredLanguages]; NSString *language = [languageArray objectAtIndex:0]; NSLog(@"语言:%@", language);//en NSLocale *locale = [NSLocale currentLocale 获取设备系统信息 http://blog.sina.com.cn/s/blog_9693f61a01017h0k.html iOS学习笔记(十三)——获取手机信息(UIDevice、NSBundle、NSLocale

    1.3K20编辑于 2022-03-08
  • 来自专栏iOS逆向与安全

    iOS小技能:金额格式处理 (货币符号本地化)

    NSLocaleKey const NSLocaleCurrencySymbol; // NSString // 获取货币符号的正确方式formatter.locale = [NSLocale currentLocale]; NSString* currencySymbol = [NSLocale.currentLocale objectForKey:NSLocaleCurrencySymbol /** NSNumberFormatterCurrencyStyle 货币形式(已本地化处理) 带货币符号 // 获取货币符号的正确方式formatter.locale = [NSLocale alloc] init]; formatter.forFoodEnergyUse = YES; [formatter.numberFormatter setLocale:[[NSLocale *locale API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0)); [formatter setLocale:[[NSLocale

    3.1K30编辑于 2022-08-22
  • 来自专栏iOS逆向与安全

    iOS小技能:自定义时间格式(适配iOS15.4之后12/24小时制的问题)

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init]; dateFormatter.locale = [[NSLocale NSDateFormatterShortStyle];// 自带的样式 [formatter setDateFormat:@"yyyy-MM-dd HH:mm"]; // 指定local,真机调试,转换时间 需要设置 NSLocale NSLocale *zh_CNLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];//zh_CN en_US en_GB NSDateFormatter*)getzh_CNLocale{ NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; NSLocale *zh_CNLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_CN"];//zh_CN en_US en_GB zh_Hans_CN

    2K20编辑于 2022-08-22
  • 来自专栏mukekeheart的iOS之旅

    OC学习12——字符串、日期、日历

    * cn = [NSLocale currentLocale]; 23 // 获取NSDate在当前Locale下对应的字符串 24 NSLog(@"%@" , [date1 dt = [NSDate dateWithTimeIntervalSince1970: 9 3600 * 24 * 366 * 20]; 10 // 创建两个NSLocale ,分别代表中国、美国 11 NSLocale* locales[] = { 12 [[NSLocale alloc] initWithLocaleIdentifier :@"zh_CN"] 13 , [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]}; 14 NSDateFormatter * df[8]; 15 //为上面2个NSLocale创建8个DateFormat对象 16 for (int i = 0 ; i < 2 ; i++) 17

    2.4K70发布于 2018-02-27
  • 来自专栏mukekeheart的iOS之旅

    iOS学习——获取iOS设备的各种信息

    在iOS中要获取设备的状态信息,主要涉及到三个类:UIDevice、NSbundle和NSlocaleNsLocale可以获取用户的本地化信息,如货币、语言、国家、数字、日期格式、地理位置显示等等。 strAppBuild = [dicInfo objectForKey:@"CFBundleVersion"]; NSLog(@"App应用Build版本:%@", strAppBuild);   NSLocale 通过NSLocale可以这样使用: NSArray *languageArray = [NSLocale preferredLanguages]; NSString *language = [languageArray objectAtIndex:0]; NSLog(@"语言:%@", language);//en NSLocale *locale = [NSLocale currentLocale

    4.3K71发布于 2018-03-01
  • 来自专栏猿人谷

    时间与日期处理

    主要有以下类: NSDate -- 表示一个绝对的时间点 NSTimeZone -- 时区信息 NSLocale -- 本地化信息 NSDateComponents -- 一个封装了具体年月日、时秒分 有下面几种初始化方法: 1. + (id)systemLocale 返回系统初始本地化信息 NSLocale *locale = [NSLocale systemLocale]; NSLog 下面的代码演示了区别所在,假设初始本地化信息为en_US,先用这两个函数分别初始化两个对象,然后修改本地化设定语言为繁体中文,再重新打印这两个对象的信息: NSLocale *locale1; NSLocale *locale2; - (IBAction)doTest:(id)sender { locale1 = [NSLocale currentLocale]; locale2 = [NSLocale *)displayNameForKey:(id)key value:(id)value 显示特定地区代号下相应键的显示名称: NSLocale *locale = [[NSLocale alloc

    3.9K70发布于 2018-01-17
  • 来自专栏清墨_iOS分享

    iOS 数字转汉字(不同语言环境)

    若要要求输出一定是中文,则再加以下代码,指定输出语言(别的语言同理): NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"zh_Hans

    2.4K20发布于 2019-03-04
  • 来自专栏iOS Developer

    iOS开发之多国语言国际化适配经验浅谈

    所以通过判断是否为中文来判断的具体写法是写了个单例的类然后写的方法: //判断是否为中文简体 - (BOOL)isSimpleChinese { NSString *language = [[NSLocale 下面是改过的代码 //判断是否为中文简体 - (BOOL)isSimpleChinese { NSString *language = [[NSLocale preferredLanguages

    1.5K30发布于 2018-06-28
  • 来自专栏mukekeheart的iOS之旅

    OC基础--字符串

    NSString *)searchString options:(NSStringCompareOptions)mask range:(NSRange)searchRange locale:(nullable NSLocale string //输出: 首字母大写: String //本地化(大写) - (NSString *)uppercaseStringWithLocale:(nullable NSLocale *)locale; //本地化(小写) - (NSString *)lowercaseStringWithLocale:(nullable NSLocale *)locale; //本地化(首字母大写 ) - (NSString *)capitalizedStringWithLocale:(nullable NSLocale *)locale; 1.8 字符串分行,分段 ////////// ////折叠////////// NSString *result3 = [string stringByFoldingWithOptions:NSNumericSearch locale:[NSLocale

    1.3K40发布于 2020-09-07
  • 来自专栏大师级码师

    UIDatePicker使用

    取出想要的地区 NSLog(@"%@", [NSLocaleavailableLocaleIdentifiers]); // 2.设置日期选择控件的地区 [datePicker setLocale:[[NSLocale UIDatePicker *datePicker = [[UIDatePickeralloc] init]; 10.2常用设置 // 设置区域为中国简体中文 datePicker.locale= [[NSLocale

    2K00发布于 2021-10-31
  • 来自专栏陈满iOS

    iOS开发·必会的算法操作:字符串数组排序+模型对象数组排序

    We now accept NSLocale. Assumes the current locale if non-nil and non-NSLocale. nil continues to mean canonical compare, which @"アいろはアイウエイウエ", @"アいろはアイウエイウエ",nil]; NSLocale *currentLocale = [NSLocale currentLocale]; NSComparator finderSortBlock = ^(id string1,id string2 *currentLocale = [NSLocale currentLocale]; NSComparator finderSortBlock = ^(id string1,id string2

    2.8K10发布于 2018-09-10
  • 来自专栏一“技”之长

    iOS开发UI之日期控件的使用(UIDatePicker)

    时间和日期模式,显示月日星期,时分上下午     UIDatePickerModeCountDownTimer, //计时模式,显示时和分 }; @property (nonatomic, retain) NSLocale

    1.3K20发布于 2018-08-15
  • 来自专栏進无尽的文章

    编码篇-开发中关于数字的那些事儿

    *discountAmount = [NSDecimalNumber decimalNumberWithString:@"123,40" locale:locale]; //123.4 NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"fr_FR"]; //法国数据格式,法国的小数点是','逗号 NSDecimalNumber decimalValue]; NSDecimal numProducts = [[NSDecimalNumber decimalNumberWithString:@"2.0"] decimalValue]; NSLocale *locale = [NSLocale currentLocale]; NSDecimal result; NSDecimalAdd(&result, &price1, &price2, NSRoundUp

    1.5K10发布于 2018-09-12
  • 来自专栏网罗开发

    iOS 获取当前时间及时间戳的互换

    小时制 NSString *formatStringForHours = [NSDateFormatter dateFormatFromTemplate:@"j" options:0 locale:[NSLocale

    3.3K30发布于 2021-01-29
  • 来自专栏华仔的技术笔记

    NSDate相差8个小时问题

    NSDateFormatter * outputFormatter = [[NSDateFormatter alloc] init]; [outputFormatter setLocale:[[NSLocale

    1K90发布于 2018-05-17
  • 来自专栏一“技”之长

    iOS10语音识别框架SpeechFramework应用

    requestAuthorization:(void(^)(SFSpeechRecognizerAuthorizationStatus status))handler; //获取所支持的所有语言环境 + (NSSet<NSLocale 这个初始化方法将默认以设备当前的语言环境作为语音识别的语言环境 - (nullable instancetype)init; //初始化方法 设置一个特定的语言环境 - (nullable instancetype)initWithLocale:(NSLocale

    1.4K20发布于 2018-08-15
  • 来自专栏iOS122-移动混合开发研究院

    Mantle--国外程序员最常用的iOS模型&字典转换框架

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; dateFormatter.locale = [[NSLocale NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; dateFormatter.locale = [[NSLocale

    2K60发布于 2018-01-02
领券