【学习ios之路:UI系列】获取ios系统版本的相关操作. 及 将汉字转化为拼音功能实现

1.获取ios系统版本的相关操作

<span style="font-size:18px;">    //iOS系统版本//系统版本,如6.2.1
    NSString *systemVersion = [[UIDevice currentDevice] systemVersion];
    NSLog(@"systemVersion = %@", systemVersion);
    
    //获取系统名称,如iPhone OS
    NSString *systemName = [[UIDevice currentDevice] systemName];
    NSLog(@"systemName = %@", systemName);
    
    //The model of the device,如iPhone或者iPod touch
    NSString *systemModel = [[UIDevice currentDevice] model];
    NSLog(@"systemModel = %@", systemModel);

    //设备的惟一标识号,deviceID
    //[[UIDevice currentDevice] userInterfaceIdiom];
    NSLog(@"%ld", [[UIDevice currentDevice] userInterfaceIdiom]);
    //设备的名称,如 张三的iPhone
    NSString *userName = [[UIDevice currentDevice] name];
    NSLog(@"userName = %@", userName);
    
    //The model of the device as a localized string,类似model
    NSString *systemLocalizedModel = [[UIDevice currentDevice] localizedModel];
    NSLog(@"systemLocalizedModel = %@", systemLocalizedModel);
</span>
2.将汉字转化为拼音,处理操作如下
<span style="font-size:18px;">NSMutableString *letter = [@"你大爷" mutableCopy];
CFStringTransform((__bridge CFMutableStringRef)letter, 0,
                                                kCFStringTransformMandarinLatin, NO);
CFStringTransform((__bridge CFMutableStringRef)letter,0,
                                              kCFStringTransformStripDiacritics, NO);
   
 NSLog(@"%@",letter);// 结果  ni  da  ye</span>

阅读更多
换一批

没有更多推荐了,返回首页