NSString的方法总结

本文详细介绍Objective-C中字符串的各种创建方式及常见操作,如比较、截取、拼接、替换等,并涉及文件读写、字符串与数组转换等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、创建常量字符串。

NSString *astring = @"This is a String!";
2、创建空字符串,给予赋值。
NSString *astring = [[NSString alloc] init];
astring = @"This is a String!";
3、在以上方法中,提升速度:initWithString方法
NSString *astring = [[NSString alloc] initWithString:@"This is a String!"];
NSLog(@"astring:%@",astring);
4、用标准c创建字符串:initWithCString方法
char *Cstring = "This is a String!";
NSString *astring = [[NSString alloc] initWithCString:Cstring];
NSLog(@"astring:%@",astring);
5、创建格式化字符串:占位符(由一个%加一个字符组成)
int i = 1;
int j = 2;
NSString *astring = [[NSString alloc] initWithString:[NSString stringWithFormat:@"%d.This is %i string!",i,j]];
6、创建临时字符串
NSString *astring;
astring = [NSString stringWithCString:"This is a temporary string"];
7、从文件创建字符串
NSString *path = [[NSBundle mainBundle] pathForResource:@"astring.text"ofType:nil];
NSString *astring = [[NSString alloc] initWithContentsOfFile:path];
NSLog(@"astring:%@",astring);
8、用字符串创建字符串,并写入到文件  
NSString *astring = [[NSString alloc] initWithString:@"This is a String!"];
NSLog(@"astring:%@",astring);
NSString *path = @"astring.text";    
[astring writeToFile: path atomically: YES];
注:此路径path只只是示意,真实路径并非如此
9、用C比较:strcmp函数
char string1[] = "string!";
char string2[] = "string!";
if(strcmp(string1, string2) == 0){
    NSLog(@"1");
}
10、isEqualToString方法    
NSString *astring01 = @"This is a String!";
NSString *astring02 = @"This is a String!";
BOOL result = [astring01 isEqualToString:astring02];
NSLog(@"result:%d",result);
11、compare方法(comparer返回的三种值)    
NSString *astring01 = @"This is a String!";
NSString *astring02 = @"This is a String!";    
BOOL result = [astring01 compare:astring02] == NSOrderedSame;  //NSOrderedSame判断两者内容是否相同
NSLog(@"result:%d",result);    
NSString *astring01 = @"This is a String!";
NSString *astring02 = @"this is a String!";
BOOL result = [astring01 compare:astring02] == NSOrderedAscending; 
//NSOrderedAscending判断两对象值的大小(按字母顺序进行比较,astring02大于astring01为真)
NSLog(@"result:%d",result);

NSString *astring01 = @"this is a String!";
NSString *astring02 = @"This is a String!";
BOOL result = [astring01 compare:astring02] == NSOrderedDescending;
//NSOrderedDescending判断两对象值的大小(按字母顺序进行比较,astring02小于astring01为真)
NSLog(@"result:%d",result);
12、不考虑大小写比较字符串
 1.NSString *astring01 = @"this is a String!"; 
  NSString *astring02 = @"This is a String!";
  BOOL result = [astring01 caseInsensitiveCompare:astring02] == NSOrderedSame;
  //NSOrderedDescending判断两对象值的大小(按字母顺序进行比较,astring02小于astring01为真)
  NSLog(@"result:%d",result); 
2.NSString *astring01 = @"this is a String!";
  NSString *astring02 = @"This is a String!"; 
  BOOL result = [astring01 compare:astring02
options:NSCaseInsensitiveSearch | NSNumericSearch] == NSOrderedSame;
  //NSCaseInsensitiveSearch:不区分大小写比较 NSLiteralSearch:进行完全比较,区分大小写 NSNumericSearch:比较字符串的字符个数,而不是字符值。 
NSLog(@"result:%d",result);
13、输出大写或者小写字符串
NSString *string1 = @"A String";  
NSString *string2 = @"String"; 
NSLog(@"string1:%@",[string1 uppercaseString]);//大写
NSLog(@"string2:%@",[string2 lowercaseString]);//小写
NSLog(@"string2:%@",[string2 capitalizedString]);//首字母大小
14、-rangeOfString: //查找字符串某处是否包含其它字符串
NSString *string1 = @"This is a string";
NSString *string2 = @"string";
NSRange range = [string1 rangeOfString:string2];
int location = range.location;
int leight = range.length;
NSString *astring = [[NSString alloc] initWithString:[NSString stringWithFormat:@"Location:%i,Leight:%i",location,leight]];
NSLog(@"astring:%@",astring);
[astring release];

示例:

NSString * str1 =@"我认为你是个好人!";
NSString * str2 =@"好人";    
//判断str1中是否含有str2,判断有没有
if([str1 rangeOfString:str2].location != NSNotFound){
    NSLog(@"这个字符串中有好人");
}

15、-substringToIndex: 从字符串的开头一直截取到指定的位置,但不包括该位置的字符

NSString *string1 = @"This is a string";
NSString *string2 = [string1 substringToIndex:3];
NSLog(@"string2:%@",string2);
16、-substringFromIndex: 以指定位置开始(包括指定位置的字符),并包括之后的全部字符
NSString *string1 = @"This is a string";
NSString *string2 = [string1 substringFromIndex:3];
NSLog(@"string2:%@",string2);
17、-substringWithRange: //按照所给出的位置,长度,任意地从字符串中截取子串
NSString *string1 = @"This is a string";
NSString *string2 = [string1 substringWithRange:NSMakeRange( 
               NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"];
[String1 insertString:@"Hi! " atIndex:0];
NSLog(@"String1:%@",String1);


18、-stringWithCapacity: //按照固定长度生成空字符串
NSMutableString *String;
String = [NSMutableString stringWithCapacity:40];
19、-appendString: and -appendFormat: //把一个字符串接在另一个字符串的末尾
NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"];
[String1 appendString:@", I will be adding some character"];
[String1 appendFormat:[NSString stringWithFormat:@", I will be adding some character"]];
NSLog(@"String1:%@",String1);
20、-insertString: atIndex: //在指定位置插入字符串
21、-setString: 
NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"]; 
[String1 setString:@"Hello Word!"];
NSLog(@"String1:%@",String1);
22、-replaceCharactersInRange: withString: //用指定字符串替换字符串中某指定位置、长度的字符串
NSMutableString *String1 = [[NSMutableString alloc] initWithString:@"This is a NSMutableString"];
[String1 replaceCharactersInRange:NSMakeRange(0, 4) withString:@"That"];
NSLog(@"String1:%@",String1);
23、-hasPrefix: //检查字符串是否以另一个字符串开头
NSString *String1 = @"NSStringInformation.txt";
[String1 hasPrefix:@"NSString"] = = 1 ?  NSLog(@"YES") : NSLog(@"NO");
[String1 hasSuffix:@".txt"] = = 1 ?  NSLog(@"YES") : NSLog(@"NO");
24、扩展路径
NSString *Path = @"~/NSData.txt";
NSString *absolutePath = [Path stringByExpandingTildeInPath];
NSLog(@"absolutePath:%@",absolutePath);
NSLog(@"Path:%@",[absolutePath stringByAbbreviatingWithTildeInPath]);
25、文件扩展名
NSString *Path = @"~/NSData.txt";
NSLog(@"Extension:%@",[Path pathExtension]);
26.NSString  获取
a、获取字符串的长度
[str length];  //这个返回一个NSUInteger  无符号的整型,占位符用 %lu
b、根据索引获得单个字符
unichar c = [str characterAtIndex:2];  返回单个字符 占位符用 %c
c、根据索引获得字符串的一个子串
[str substringFromIndex:3];        从给定的索引开始(包含该索引位置)截取到字符串末尾
[str substringToIndex:3];    截取字符串到给定索引的位置结束,(不包含该索引位置)
d、截取字符串的某一段
NSRange rang = {4,6};   起始位置是4,从第四个截取长度为6
//location (起始索引的位置,包含该索引) length(要截取的长度)
NSString * tmpStr3 = [str3 substringWithRange:rang];
e、获得一个字符串的索引位置
[str1 rangeOfString:tmpStr1]; 
//返回NSRange  可以用NSStringFromRange(tmpRange) 输出,tmpRange.location == NSNotFound  判断是否找到字符串tmpStr
27、字符串判断
a、//用来判断字符串是否为空
str == nil || str.length == 0 
b、判断字符串是否已指定的内容开头
[str hasPrefix:@“abc”]; 返回 BOOL
c、判断字符串是否以指定的内容结尾
[str hasSuffix:@“.txt"];返回BOOL 在开发中常用于判断文件格式
d、判断两个字符串是否相等
str1 == str2  使用 ==号 判断两个字符串 实际上是判断的字符串地址是否相同
[str1 isEqualToString:str2]  判断字符串内容是否相等
e、compare 是isEqualToString的增强版本
NSComparisonResult result = [strTmp1 compare:strTmp2];
返回两个字符串是升序 降序还是相等
NSOrderedAscending 升序
NSOrderedSame    相等
NSOrderedDescending 降序
28、类型转换
a、int类型换换成字符串
NSString *str=[NSString stringWithFormat:@“%d”,a];
b、float -> NSString
NSString * str = [NSString stringWithFormat:@“%.2f",f];  
//%.2f 表示两位小数 . double和float一样
c、char - > NSString
NSString * str = [NSString stringWithFormat:@“%c",c];
d、NSString 转换成普通数据类型
[str intValue];
[str floatValue];
[str doubleValue];
e、将字符串中的字母转换成大写
[str uppercaseString];  转成大写
[str lowercaseString];  转成小写
f、将首字母大写
[str capitalizedString];
29、字符串重组
a、多个数据拼接成一个字符串
NSString * date = [NSString stringWithFormat:@"%d年%d月%d日”,year,month,day];
b、字符串的末尾追加新的字符
[str stringByAppendingString:@“我是追加的"];
c、在制定的范围追加字符串
NSRange range = {4,0};  从第四个索引开始,覆盖0个字符
location代表的时从哪个索引开始插入,length 代表的意思可以覆盖几个字符
NSString * str4 = [str stringByReplacingCharactersInRange:range withString:@“插入的"];
d、使用新的字符,替换原有的字符
[str stringByReplacingOccurrencesOfString:@"w" withString:@“a"];
e、在字符串中删除特定的某些字符
[str stringByReplacingOccurrencesOfString:@"-" withString:@“"];
//将想要删除的字符 替换成空的字符</span>
f、去掉字符串中的空格
[str stringByReplacingOccurrencesOfString:@" " withString:@“"];
//将空格替换成空字符
30、将字符串写入文件
NSString * content = @"要写入的内容";
NSString * path = @“/Users/xxx/Desktop/mytest.txt";      //路径
//1.参数1 要给入文件目录(并且要包括文件名称)
//2.atomically : YES
//3.NSUTF8StringEncoding 国际通用的编码格式
//4.NSError 是用来记录错误信息的
NSString * path = @"/Users/xxxx/Desktop/mytest.txt";
NSError * error;
NSString * str = [NSString stringWithContentsOfFile:path  encoding:NSUTF8StringEncoding error:&error];
if (error != nil)
{
NSLog(@"error message %@",error);
}
else
{
NSLog(@"str content %@",str);
}
NSError * error;
BOOL isWriteSuccess = [content writeToFile:path atomically:YES   encoding:NSUTF8StringEncoding error:&error];
if(isWriteSuccess)
{
NSLog(@"文件创建成功");
}
else
{
NSLog(@"error %@",error);
}
31、从文件中读取字符串
NSString * path = @"/Users/xxxx/Desktop/mytest.txt";
NSError * error;
NSString * str = [NSString stringWithContentsOfFile:path  encoding:NSUTF8StringEncoding error:&error];
if (error != nil){
NSLog(@"error message %@",error);
}else{
NSLog(@"str content %@",str);
}
32、可变长度字符串 NSMutableString
NSMutableString继承自 NSString 拥有NSString的所有属性和方法。
a、初始化    
NSMutableString * muStr = [[NSMutableString alloc] initWithCapacity:0];
初始化一个空字符串
[muStr setString:@“aa"];//给字符串设置内容
//动态的给字符串末尾追加新值
[muStr appendString:@“cc"];  
//在指定的索引位置,插入字符串
[muStr insertString:@"bb" atIndex:2];
//删除指定范围的字符串
//你要删除的长度,一定不能够超出字符串的的长度,导致异常Range or index out of bounds
NSRange range = {3,7};
[muStr deleteCharactersInRange:range];
//替换
[muStr replaceCharactersInRange:range withString:@“content’"];

33、字符串与数组的相互转换

1、将数组里面的元素拼接成字符串。
      注意:元素本身就是字符。

self.appendString = [stringArr componentsJoinedByString:@";"];
2、将字符串根据分隔号转成数组。
      //其中 ; 分号必须是 隔断字符串 的分隔符。否则 ; 就要更改成对应的 分隔符 
NSArray* array = [self.appendString componentsSeparatedByString:@";"];

3、假如字符串中数据较多,可以通过

      //将字符串转成NSData然后,通过 NSJSONSerialization 方法实现转成数组的效果

   NSData *data = [[self resultStr] dataUsingEncoding:NSUnicodeStringEncoding];
   NSArray *array = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];

34、String 与结构的相关转换
 1>CGAffineTransformFromString
/**
 *  一个内容如"{a,b,c,d,tx,ty}"的字符串,a,b,c,d,tx,ty 都是CGAffineTransform数据结构体的float类型的组成部分。
举个有效字符串的例子 @”{1,0,0,1,2.5,3.0}” 。
这个字符串不是本地化的,因此其中的内容常常用逗号隔开。
如果这个字符串不是格式化化好的,那么这个方法返回恒等变换。
大体上,你使用这个方法仅仅用来转换先前通过 NSStringFromCGAffineTransform 这个方法生成的字符串。
 */
CGAffineTransform CGAffineTransformFromString(NSString *string);  

 2>CGPointFromString
/**
 *  把字符串@"{x, y}"转换成CGPoint。
 */
   CGPoint CGPointFromString(NSString *string);  
 3>CGRectFromString
/**
 *  把字符串@"{{x, y}, {width, height}}"转换成CGRect。
 */
 CGRect CGRectFromString(NSString *string);  
 4>CGSizeFromString
/**
 *  把字符串@"{width, height}"转换成CGSize。
 */
  CGSizeFromString(NSString * string);
5>UIEdgeInsetsFromString
/**
 *  返回对应于哥顶字符串数据众的UIKit边缘凹凸数据结构。
    string:
    一个内容为@"{top, left, bottom, right}"结构的字符串。top, left, bottom, right都是 UIedgeInsets 结构体的float类型的组成数据。
    例如,@”{1.0,2.0,3.0,4.0}”.
 */
  UIEdgeInsets UIEdgeInsetsFromString(NSString *string);  
 6>NSStringFromUIOffset
/**
 *  把UIOffset(horizontal, vertical)转换成字符串。
 */
   NSString *NSStringFromUIOffset(UIOffset offset);  
 7>NSStringFromCGAffineTransform
/**
 *  把 CGAffineTransform 格式的数据转换成字符串。
 */
NSString *NSStringFromCGAffineTransform(CGAffineTransform transform);  
  8>NSStringFromCGPoint
/**
 *  把CGPoint转换成字符串@"{x, y}".
 */
NSString *NSStringFromCGPoint(CGPoint point);  
  9>NSStringFromCGRect
/**
 *  把CGSize转换成字符串@"{width, heigh}".
 */
NSString *NSStringFromCGSize(CGSize size);  
 10>NSStringFromCGRect
 /**
  *  把CGRect转换成字符串@"{{x, y}, {width, heigh}}".
  */
NSString *NSStringFromCGRect(CGRect rect);  

 11>NSStringFromUIEdgeInsets

 /**
  *  把UIEdgeInsets转换成字符串。
  */
NSString *NSStringFromUIEdgeInsets(UIEdgeInsets insets);  

12>NSStringFromUIOffset
 /**
  *  把UIOffset转换成字符串。
  */
NSString *NSStringFromUIOffset(UIOffset offset);  
35. 拓展
  1>Managing Edge Insets

UIEdgeInsets UIEdgeInsetsMake
/**
 *  为一个button或者view创建一个边框偏移。
    为绘制的矩形区域添加外边距,每一个边都可以有一个不同的值。
 */
UIKIT_STATIC_INLINE UIEdgeInsets UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right) {  
    UIEdgeInsets insets = {top, left, bottom, right};  
    return insets;  
}  
UIEdgeInsetsEqualToEdgeInsets
/**
 *  判断两个UIEdgeInsets是否相同。
 */
UIKIT_STATIC_INLINE BOOL UIEdgeInsetsEqualToEdgeInsets(UIEdgeInsets insets1, UIEdgeInsets insets2) {  
    return insets1.left == insets2.left && insets1.top == insets2.top 
    && insets1.right == insets2.right && insets1.bottom == insets2.bottom;  
}  
UIEdgeInsetsInsetRect
/**
 *  按照给丁的UIEdgeInsets调整CGRect。
 */
UIKIT_STATIC_INLINE CGRect UIEdgeInsetsInsetRect(CGRect rect, UIEdgeInsets insets) {  
    rect.origin.x    += insets.left;  
    rect.origin.y    += insets.top;  
    rect.size.width  -= (insets.left + insets.right);  
    rect.size.height -= (insets.top  + insets.bottom);  
    return rect;  
}  
  2>Managing Offsets
  UIOffsetMake
/**
 *  创建UIOffset。
 */
UIKIT_STATIC_INLINE UIOffset UIOffsetMake(CGFloat horizontal, CGFloat vertical) {  
    UIOffset offset = {horizontal, vertical};  
    return offset;  
}  
UIOffsetEqualToOffset
/**
 *  判断两个UIOffset是否相等。
 */
UIKIT_STATIC_INLINE BOOL UIOffsetEqualToOffset(UIOffset offset1, UIOffset offset2) {  
    return offset1.horizontal == offset2.horizontal && offset1.vertical == offset2.vertical;  
}  

3>Interface Orientation Macros

UIInterfaceOrientationIsPortrait
/**
 *  判断当前界面方向是不是竖屏的。
    界面方向可以与设备方向不同。你通常使用这个宏在ViewContrller中查看当前界面方向。
 */
#define UIInterfaceOrientationIsPortrait(orientation)  
((orientation) == UIInterfaceOrientationPortrait || (orientation) == UIInterfaceOrientationPortraitUpsideDown)  

UIInterfaceOrientationIsLandscape
/**
 *  判断界面方向是不是横屏的。用法同 UIInterfaceOrientationIsPortrait 。
 */
#define UIInterfaceOrientationIsLandscape(orientation) 
((orientation) == UIInterfaceOrientationLandscapeLeft || (orientation) == UIInterfaceOrientationLandscapeRight)  

4>Device Orientation Macros
UIDeviceOrientationIsValidInterfaceOrientation
/**
 *  判断设备的转向是否是有效的。
 */
#define UIDeviceOrientationIsValidInterfaceOrientation(orientation) 
((orientation) == UIDeviceOrientationPortrait || (orientation) == UIDeviceOrientationPortraitUpsideDown || (orientation) 
== UIDeviceOrientationLandscapeLeft || (orientation) == UIDeviceOrientationLandscapeRight)  

例子:  
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration  
{  
    //先判断是否有效转向  
    if( UIDeviceOrientationIsValidInterfaceOrientation( toInterfaceOrientation ) )  
    {  
        // Do what you want to do....  
    }  
}  

UIDeviceOrientationIsPortrait
/**
 *  判断设备是不是竖屏的。
    Declared  In UIDevice.h.
 */
#define UIDeviceOrientationIsPortrait(orientation)  
((orientation) == UIDeviceOrientationPortrait || (orientation) == UIDeviceOrientationPortraitUpsideDown)  

UIDeviceOrientationIsLandscape
/**
 *  判断设备是不是横屏的。
     Declared  In UIDevice.h.
 */
#define UIDeviceOrientationIsLandscape(orientation) 
((orientation) == UIDeviceOrientationLandscapeLeft || (orientation) == UIDeviceOrientationLandscapeRight)  

  5>Interface Idiom Macro
UI_USER_INTERFACE_IDIOM
/**
 *  判断当前设备是否支持 interface idiom。
    如果当前设备为iPhone 或者iPod touch,那么userInterfaceIdiom就为UIUserInterfaceIdiomPhone,如果为iPad就为UIUserInterfaceIdiomPad.
    Declared  In UIDevice.h.
 */
#define UI_USER_INTERFACE_IDIOM() 
([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] ? 
[[UIDevice currentDevice] userInterfaceIdiom] : UIUserInterfaceIdiomPhone)  
6>Accessibility
UIAccessibilityPostNotification
/**
 *  传递一个消息给辅助的应用。
    如果你向要你的用户界面组件流畅的改变或者流畅的出现和消失,那么你的应用或许需要传递辅助性的消息。
    Declared In UIAccessibility.h
 */
void UIAccessibilityPostNotification(UIAccessibilityNotifications notification, id argument);  
UIAccessibilityIsVoiceOverRunning
/**
 *  判断VoiceOver是否打开(运行)。
    可以监听 UIAccessibilityVoiceOverStatusChanged 这个消息来判断VoiceOver的状态。
    Declared In UIAccessibility.h
 */
BOOL UIAccessibilityIsVoiceOverRunning() NS_AVAILABLE_IOS(4_0);  
UIAccessibilityIsClosedCaptioningEnabled
/**
 *  判断隐藏式字幕是否可用。
    Declared In UIAccessibility.h
 */
BOOL UIAccessibilityIsClosedCaptioningEnabled() NS_AVAILABLE_IOS(5_0);  
UIAccessibilityRequestGuidedAccessSession
/**
 *  通用->辅助功能->引导式访问。
    enable:
     YES是在当前应用程序中把设备设置成单应用模式,NO退出单应用模式。
    completionHandler:
     这个block会通知你的App操作成功还是失败。
    Declared In UIAccessibility.h
 */
void UIAccessibilityRequestGuidedAccessSession(BOOL enable, void(^completionHandler)(BOOL didSucceed)) NS_AVAILABLE_IOS(7_0);  
UIAccessibilityIsGuidedAccessEnabled
/**
 *  判断引导式访问功能是否可用。
     Declared In UIAccessibility.h
 */
BOOL UIAccessibilityIsGuidedAccessEnabled() NS_AVAILABLE_IOS(6_0);  

UIAccessibilityIsInvertColorsEnabled
/**
 *  判断通用->辅助功能->翻转颜色是否是可用的。
Declared In UIAccessibility.h
 */
BOOL UIAccessibilityIsInvertColorsEnabled() NS_AVAILABLE_IOS(6_0);  
UIAccessibilityIsMonoAudioEnabled
/**
 *  判断通用->辅助功能->单声道饮品是否是打开的。
     Declared In UIAccessibility.h
 */
BOOL UIAccessibilityIsMonoAudioEnabled() NS_AVAILABLE_IOS(5_0);  
UIAccessibilityZoomFocusChanged
/**
 *  通用->辅助功能->缩放。
    通知系统应用程序的焦点改变到了一个新的位置。
     type:
     聚焦类型。
     frame:
     在屏幕坐标系中,缩放的框架。
     view:
     包含缩放框架的view。
      Declared In UIAccessibilityZoom.h
 */
void UIAccessibilityZoomFocusChanged(UIAccessibilityZoomType type, CGRect frame, UIView *view) NS_AVAILABLE_IOS(5_0);  
UIAccessibilityRegisterGestureConflictWithZoom
/**
 *  如果你的App所使用的多手指手势与系统的缩放手势(用三个手指的)冲突了,调用这个方法来通知用户这个冲突。
    Declared In UIAccessibilityZoom.h
 */
void UIAccessibilityRegisterGestureConflictWithZoom() NS_AVAILABLE_IOS(5_0);  
UIAccessibilityConvertFrameToScreenCoordinates
/**
 *  把指定矩形的视图坐标转换成屏幕坐标系统。
    rect:
    在指定view坐标系中的特定矩形区域。
    view:
    包含特定矩形的view。这个参数不能为nil。
     Declared In UIAccessibility.h
 */
UIAccessibilityConvertFrameToScreenCoordinates(CGRect rect, UIView *view) NS_AVAILABLE_IOS(7_0);  
UIAccessibilityConvertPathToScreenCoordinates
/**
 *  把指定的路径对象转换成屏幕坐标系统的并且返回一个有结果的新路径对象。路径样式一样,但是路径上的点是屏幕坐标系的。
    path:
    你想转换的路径对象。创建路径对象的坐标值应当是相对指定view坐标系统来说的。这个参数不能为nil.
    view:
    用来定义路径坐标系的view。这个参数不能为nil.
    Declared In UIAccessibility.h
 */
UIBezierPath *UIAccessibilityConvertPathToScreenCoordinates(UIBezierPath *path, UIView *view) NS_AVAILABLE_IOS(7_0);  
 7>Text Manipulations
NSTextAlignmentFromCTTextAlignment
/**
 *  把一个UIKit 文本对齐常量转换成可以被Core Text使用的与之匹配的常量值。
nsTextAlignment:
你想转换测UIKit 文本对齐常量。
当你需要在UIKit和Core Text对齐常量之间进行映射的时候就调用这个方法。
Declared In NSText.h。
 */
CTTextAlignment NSTextAlignmentToCTTextAlignment(NSTextAlignment nsTextAlignment);
NSTextAlignmentToCTTextAlignment
/**
 *  与 NSTextAlignmentFromCTTextAlignment 相对的方法。
     Declared In NSText.h。
 */
CTTextAlignment NSTextAlignmentToCTTextAlignment(NSTextAlignment nsTextAlignment);  
 8>Guided Access Restriction State
UIGuidedAccessRestrictionStateForIdentifier
/**
 *  返回指定引导访问限制的限制状态。
     restrictionIdentifier:
     引导访问限制的唯一地标识字符串。
     所有限制的初始化状态为 UIGuidedAccessRestrictionStateAllow.
     Declared In UIGuidedAccessRestrictions.h
 */
UIGuidedAccessRestrictionState UIGuidedAccessRestrictionStateForIdentifier(NSString *restrictionIdentifier) NS_AVAILABLE_IOS(7_0);  










评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值