UIKit Function Reference

    xiaoxiao2021-03-25  95

    转自:http://blog.csdn.net/lixuwen521/article/details/16879597

    Application Launch

    UIApplicationMain

    [objc]  view plain  copy   int UIApplicationMain(int argc, charchar *argv[], NSString *principalClassName, NSString *delegateClassName);   应用程序启动入口。 argc: 在argv中的参数个数。 argv: 参数列表。

    principalClassName:

    UIApplication类或者其子类的名字。如果为设置nil,info.plist中的NSPrincipalClass字段的值将被采用。如果没有指定NSPrincipalClass字段,就将使用UIApplication类,代理类将会被实例化。

    delegateClassName:

    被实例化的应用代理类名。如果delegateClassName指定了一个UIApplication的子类,那么指定这个子类为代理;子类的实例会收到应用代理的消息。如果从应用程序的主nib文件众加载代理对象,那么就设置为nil。

    尽管这个方法声明了返回值,但是它永远不会返回。

    Image Manipulation

    UIImageJPEGRepresentation

    [objc]  view plain  copy   NSData *UIImageJPEGRepresentation(UIImage *image, CGFloat compressionQuality);   返回指定图像JPEGG格式的数据。

    image:

    原始图片数据。

    compressionQuality:

    返回的JEPG图片的质量,这个值是从0.0-1.0. 0.0表示最大程度的压缩(质量最低的)当然1.0表示最低压缩(也就是质量最高的)。 如果图片不包含CGImageRef或者不合法的位图格式就返回nil。

    UIImagePNGRepresentation

    [objc]  view plain  copy   NSData *UIImagePNGRepresentation(UIImage *image);   返回指定图像PNG格式的数据。 同 UIImageJPEGRepresentation 。

    Image and Movie Saving

    UIImageWriteToSavedPhotosAlbum

    [objc]  view plain  copy   void UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, voidvoid *contextInfo);   添加指定图片到用户相册。 completionSelector: completionTarget对象调用的方法选择器。这个可以选择的方法应当遵循如下格式 - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo; contextInfo: 可选择的参数。这个参数是你想传入 completionSelector 方法的特定上下文信息。 当在UIImagePickerController中使用时,应当相应的在 imagePickerController:didFinishPickingMediaWithInfo:  这个方法的实现中调用。 如果所用设备没有相机,这个方法会把图片保存到照片专辑中,而不是相机交卷专辑。

    UISaveVideoAtPathToSavedPhotosAlbum

    [objc]  view plain  copy   void UISaveVideoAtPathToSavedPhotosAlbum(NSString *videoPath, id completionTarget, SEL completionSelector, voidvoid *contextInfo) NS_AVAILABLE_IOS(3_1);   添加指定视频到用户相册。 参数同 UIImageWriteToSavedPhotosAlbum ,只是第一个参数不同,videoPath是video文件的路径。 completionSelector 的方法是 - (void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo; 在调用这个方法之前,调用 UIVideoAtPathIsCompatibleWithSavedPhotosAlbum 这个方法来判断是否可以把视频保存到相机交卷专辑。

    UIVideoAtPathIsCompatibleWithSavedPhotosAlbum

    [objc]  view plain  copy   BOOL UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(NSString *videoPath) NS_AVAILABLE_IOS(3_1);   返回一个BOOL值,这个值表示是否可以把指定的视频文件存放到用户的相机交卷专辑。 存放在用户相机胶卷专辑中的视频文件并不是所有的设备都能播放的。在尝试存储视频之前,调用这个方法检查一下这个设备是否支持保存这个视频。

    Creating a Dictionary

    [objc]  view plain  copy   #define NSDictionaryOfVariableBindings(...) _NSDictionaryOfVariableBindings(@"" # __VA_ARGS__, __VA_ARGS__, nil)   创建一个字典,这个字典中与value值相关联的key值为字符串。

    当创建自动布局约束的时候这个宏是特别有用的。

    NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(button1, button2);

    creates the dictionary { @"button1" = button1, @"button2 = button2 }.

    NSDictionaryOfVariableBindings(v1, v2, v3)  与  [NSDictionary dictionaryWithObjectsAndKeys:v1, @"v1", v2, @"v2", v3, @"v3", nil]; 是一样的。

    Graphics

    UIGraphicsGetCurrentContext

    [objc]  view plain  copy   CGContextRef UIGraphicsGetCurrentContext(void);   返回当前图形上下文。 当前的图形上下文默认是nil。view对象在调用自己的 drawRect:  方法之前需要把一个有效的图形上下文放到栈中并作为当前图形上下文。如果你不使用UIView对象做绘制,那么你必须手动调用 UIGraphicsPushContext 这个方法把一个有效的图形上下文放到栈中。 在iOS4以后的系统中,你可以在你的应用程序的任何线程中调用这个方法。

    UIGraphicsPushContext

    [objc]  view plain  copy   void UIGraphicsPushContext(CGContextRef context);   把指定的图形上下文作为当前图形上下文。 你可以使用这个方法来保存上一个图形上下文的状态,并且把指定的上下文作为当前的。 使用这个方法时必须和 UIGraphicsPopContext 这个方法配对使用。 在iOS4以后的系统中,你可以在你的应用程序的任何线程中调用这个方法。

    UIGraphicsPopContext

    [objc]  view plain  copy   void UIGraphicsPopContext(void);   把当前的图形上下文从栈顶移除,并且回复上一个图形上下文。 使用这个方法时必须和 UIGraphicsPushContext 这个方法配对使用。 在iOS4以后的系统中,你可以在你的应用程序的任何线程中调用这个方法。

    UIGraphicsBeginImageContext

    [objc]  view plain  copy   void UIGraphicsBeginImageContext(CGSize size);   创建一个基于位图的图形上下文并且把它作为当前的图形上下文。 这个方法相当于调用 UIGraphicsBeginImageContextWithOptions  这个方法,并且把不透明参数设置为NO和把放大缩小参数设置为1.0. 在iOS4以后的系统中,你可以在你的应用程序的任何线程中调用这个方法。

    UIGraphicsBeginImageContextWithOptions

    [objc]  view plain  copy   void UIGraphicsBeginImageContextWithOptions(CGSize size, BOOL opaque, CGFloat scale) NS_AVAILABLE_IOS(4_0);   创建一个带指定设置的基于位图的图形上下文。 size: 新基于位图的图形上下文的大小。这个代表了通过 UIGraphicsGetImageFromCurrentImageContext 这个方法返回的图片的大小。要获得以像素为单位的位图大小,必须用宽度和高度的值乘以scale参数的值。 opaque: 一个表示这个位图图形上下文是否是不透明的BOOL值。如果你知道这个位图是完全不透明的,那么设置为YES来忽略alpha通道和优化位图的存储。设置NO就意味着这个位图必须要包含一个alpha通道来处理任何部分透明的像素。 scale: 适应于位图的缩放系数。如果制定这个值为0.0,那么这个缩放系数就被设置成设备主屏幕的缩放系数。 使用这个方法配置绘图环境来渲染到位图上。位图格式如下: 1.iOS3.2以后创建的位图,绘图环境使用预乘的ARGB格式来存储位图数据。如果opaque参数设置为YES,位图会以完全不透明和alpha通道被忽略来对待。 2.iOS3.1以前创建的位图,绘图环境使用预乘的RGBA格式来存储位图数据。 这个环境使用默认的UIKit视图坐标系统。起点在左上角,正轴向下延伸并且在原点的右侧。提供的缩放系数同样应用到坐标系和生成的图片上。这个绘图环境立刻被压到图形上下文栈中。 当通过这个方法创建的上下文为当前图形上下文时,可以调用 UIGraphicsGetImageFromCurrentImageContext 这个方法重新获取一个基于当前图形上下文内容的图片对象。当你修改完这个上下文时,必须要调用 UIGraphicsEndImageContext 这个方法来清除位图绘制环境和从当前图形上下文栈顶移除这个上下文。不可以调用 UIGraphicsPopContext 这个方法从栈中移除这种类型的图形上下文。 在其它大多数方面,通过这个方法创建的图形上下文的行为和其它图形上下文都很相似。你可以通过push和pop其它的图形上下文来change这个上下文。你同样可以通 UIGraphicsGetCurrentContext 这个方法来获得位图图形上下文。 在iOS4以后的系统中,你可以在你的应用程序的任何线程中调用这个方法。

    UIGraphicsGetImageFromCurrentImageContext

    [objc]  view plain  copy   UIImage* UIGraphicsGetImageFromCurrentImageContext(void);   获得一个基于位图的图形上下文的内容的图片。 只有一个基于位图的图形上下文为当前图形上下文时,才可以调用这个方法。如果当前上下文为nil或者不是通过 UIGraphicsBeginImageContext 创建的,这个方法返回nil。 在iOS4以后的系统中,你可以在你的应用程序的任何线程中调用这个方法。

    UIGraphicsEndImageContext

    [objc]  view plain  copy   void UIGraphicsEndImageContext(void);    从栈顶移除当前的基于位图的图形上下文。 使用这个方法来清除在栈顶通过 UIGraphicsBeginImageContext 这个方法生成的绘图环境,和相应的基于位图的图形上下文。 如果当前的图形上下文不是通过 UIGraphicsBeginImageContext 这个方法生成的,那么这个方法什么也不做。 在iOS4以后的系统中,你可以在你的应用程序的任何线程中调用这个方法。

    UIRectClip

    [objc]  view plain  copy   void UIRectClip(CGRect rect);   修改与当前剪切路径相交的矩形区域。 每次调用这个方法一支缩小当前图形上下文中指定区域的剪切路径。不可以通过这个方法扩展剪切范围路径。如果当前图形上下文为nil,这个方法什么也不做。 在你的绘制代码中,如果你需要返回当前剪切路径到原始形状,你需要在调用这个方法之前保存当前图形上下文。在你做修改之前,调用 CGContextSaveGState 这个方法来保存当前图形上下文的状态。当你准备好恢复原始剪切区域,你可以使用 CGContextRestoreGState  这个方法来恢复上一个图形的状态。 在iOS4以后的系统中,你可以在你的应用程序的任何线程中调用这个方法。 [objc]  view plain  copy   例子:获取一块区域   - (UIImage *)getImage   {       UIGraphicsBeginImageContext(self.bounds.size);       CGContextRef context = UIGraphicsGetCurrentContext();       CGContextSaveGState(context);       UIRectClip(CGRectMake(0.00.0self.bounds.size.widthself.bounds.size.height / 2.0));       [self.layer renderInContext:context];       UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();       UIGraphicsEndImageContext();              return theImage;   }  

    UIRectFill

    [objc]  view plain  copy   void UIRectFill(CGRect rect);   用当前的颜色来填充指定的区域。 用当前图形上下文的填充颜色和 kCGBlendModeCopy 混合模式来填充指定区域。 在iOS4以后的系统中,你可以在你的应用程序的任何线程中调用这个方法。 [objc]  view plain  copy   例子:用红色填充一个矩形   CGContextRef context = UIGraphicsGetCurrentContext();          CGContextSetRGBFillColor(context, 1.00.00.01.0);          UIRectFill(CGRectMake(100.0100.0100.0100.0));  

    UIRectFillUsingBlendMode

    [objc]  view plain  copy   void UIRectFillUsingBlendMode(CGRect rect, CGBlendMode blendMode);   在当前图形上下文中绘制矩形区域。如果当前图形上下文为nil,这个方法什么也不做。 在iOS4以后的系统中,你可以在你的应用程序的任何线程中调用这个方法。

    UIRectFrame

    [objc]  view plain  copy   void UIRectFrame(CGRect rect);   围绕指定矩形内部区域绘制一个框架。 这个方法用当前图形上下文的填充颜色和 kCGBlendModeCopy 混合模式在矩形内部绘制了一个框架。在当前坐标系内宽度是1.0。由于在矩形内部绘制这个框架,即使是绘制剪切矩形,它依然是可见的。如果当前图形上下文为nil,这个方法什么也不做。 因为这个方法不是直接在线上画,但是在它里面,它使用当前的填充颜色而不是画笔颜色。 在iOS4以后的系统中,你可以在你的应用程序的任何线程中调用这个方法。 [objc]  view plain  copy   例子:绘制一个矩形边框   UIRectFrame(CGRectMake(100.0100.0100.0100.0));  

    UIRectFrameUsingBlendMode

    [objc]  view plain  copy   void UIRectFrameUsingBlendMode(CGRect rect, CGBlendMode blendMode);   同 UIRectFrame方法,多了一个混合模式。 在iOS4以后的系统中,你可以在你的应用程序的任何线程中调用这个方法。

    PDF Creation

    UIGraphicsBeginPDFContextToData

    [objc]  view plain  copy   void UIGraphicsBeginPDFContextToData(NSMutableData *data, CGRect bounds, NSDictionary *documentInfo) NS_AVAILABLE_IOS(3_2);   创建一个目标为指定可变数据对象的基于PDF的图形上下文。 data: 存储要输出的PDF文件数据 bounds: 一个指定大小和位置的PDF页面大小。对于每一个新的PDF页面来说,这个值往往被看成默认的media box。矩形的原点通常是(0,0)点。指定一个空的矩形的页面大小是8.5x11英寸(612x792像素)。 documentInfo : 一个和指定与PDF文件相关联的额外信息的字典。你可以使用这些key为PDF来指定额外的元数据和加密信息,比如PDF的作者或者访问PDF的密码。字典中的这些key值和你传给 CGPDFContextCreate 这个方法的一样,这些key在 CGPDFContext Reference 中有解释。字典是被新图形上下文保留的,当返回给你了,就可以安全释放了。 如果不想给PDF文档关联额外的信息就设置为nil。 在创建完这个图形上下文之后,这个上下文就是当前绘图上下文。任何后来的绘制命令都被捕获到并且转换成PDF数据。当完成绘制时,你需要调用 UIGraphicsEndPDFContext 这个方法来关于PDF图形上下文。 你可以使用你通常使用的所有的相同的绘制程序来绘制应用程序的内容。图形上下文把所有的绘制命令自动的转换成PDF的绘制命令。然后,在向PDF图形上下文发出绘制命令之前,必须要通过 UIGraphicsBeginPDFPage  或者 UIGraphicsBeginPDFPageWithInfo  方法来开始一个新的页面。以后你同样可以使用这些方法来定义额外的页面。 创建完成之后,你可以通过 UIGraphicsGetCurrentContext 方法来获得一个PDF图形上下文。 [objc]  view plain  copy   例子:   NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/abc.pdf"];              NSMutableData *data = [[NSMutableData alloc] init];              UIGraphicsBeginPDFContextToData(data, CGRectZero, nil);   UIGraphicsBeginPDFPageWithInfo(CGRectMake(00612792), nil);              CGContextRef context = UIGraphicsGetCurrentContext();              [_imageView.layer renderInContext:context];              [@"Hello PDF!" drawAtPoint:CGPointMake(380.0100.0) withFont:[UIFont boldSystemFontOfSize:30.0]];              UIGraphicsEndPDFContext();              [data writeToFile:path atomically:YES];  

    UIGraphicsBeginPDFContextToFile

    [objc]  view plain  copy   <span style="font-weight: normal;"><span style="font-size: 12px;">BOOL UIGraphicsBeginPDFContextToFile(NSString *path, CGRect bounds, NSDictionary *documentInfo) NS_AVAILABLE_IOS(3_2);</span></span>  

    存储PDF文件的路径,可以是相对路径也可以是绝对路径。如果在指定的路径下没有这个文件,那么就创建一个文件;相反,已经存在的文件内容就会被清除。目录路径必须存在。

    其它与 UIGraphicsBeginPDFContextToData 相同。 [objc]  view plain  copy   例子:   NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/abc.pdf"];          UIGraphicsBeginPDFContextToFile(path, CGRectZero, nil);   UIGraphicsBeginPDFPageWithInfo(CGRectMake(00612792), nil);          CGContextRef context = UIGraphicsGetCurrentContext();          [_imageView.layer renderInContext:context];          [@"Hello PDF!" drawAtPoint:CGPointMake(380.0100.0) withFont:[UIFont boldSystemFontOfSize:30.0]];          UIGraphicsEndPDFContext();  

    UIGraphicsEndPDFContext

    [objc]  view plain  copy   void UIGraphicsEndPDFContext(void) NS_AVAILABLE_IOS(3_2);   关闭PDF图形上下文并从当前图形上下文栈顶弹出。

    在完成一个PDF图形上下文的绘制时必须调用这个方法。这个方法关闭当前打开的页面并且把PDF图形上下文从栈中移除,同样也会释放与PDF上下文相关的 CGContextRef 实例。如果当前的不是PDF上下文,这个方法什么也不做。

    void UIGraphicsBeginPDFPage(void)NS_AVAILABLE_IOS(3_2);

    UIGraphicsBeginPDFPage

    [objc]  view plain  copy   void UIGraphicsBeginPDFPage(void) NS_AVAILABLE_IOS(3_2);   在PDF图形上下文中标记一个新的页面并使用默认值进行配置。

    这个方法在开启一个新的页面之前会结束任何上一个页面。当你创建完PDF图形上下文时会给指定矩形区域内的新页面设置一个媒体盒。

    如果当前的上下文不是一个PDF图形上下文,那么这个方法什么也不做。

    在你发出任何绘制命令之前,你必须要调用这个方法或者 UIGraphicsBeginPDFPageWithInfo 这个方法。

    UIGraphicsBeginPDFPageWithInfo

    [objc]  view plain  copy   void UIGraphicsBeginPDFPageWithInfo(CGRect bounds, NSDictionary *pageInfo) NS_AVAILABLE_IOS(3_2);   在PDF图形上下文中标记一个新的页面并使用指定的值进行配置。

    bounds:

    新PDF页面中指定大小和位置的矩形框。这个矩形相当于页面的媒体框矩形。

    pageInfo:

    一个指定特定额外与页面相关信息的字典,比如定义页面不同部分的矩形框。有一个数组的keys你可以在这个字典众使用,在 CGPDFContext Reference 中查看box 字典keys。这个字典是这个新页面所拥有的,所以在这个方法返回之后你需要释放这个字典。

    如果你这个页面不想使用任何额外的信息那么就设定为nil。

    这个方法在开启一个新的页面之前会结束任何上一个页面。设置新页面媒体框的值在pageInfo字典的 kCGPDFContextMediaBox key中,或者如果这个字典不包含这个key,那么这个值就在bounds参数中。

    如果当前的上下文不是一个PDF图形上下文,那么这个方法什么也不做。

    在你发出任何绘制命令之前,你必须要调用这个方法或者 UIGraphicsBeginPDFPageWithInfo 这个方法。

    UIGraphicsGetPDFContextBounds

    [objc]  view plain  copy   CGRect UIGraphicsGetPDFContextBounds(void) NS_AVAILABLE_IOS(3_2);  

    返回与PDF上下文关联的当前页面边界或者如果当前上下文不是PDF图形上下文就返回CGRectZero。

    如果一个页面还没有开始绘制,这个方法返回当创建PDF图形上下文时指定的默认媒体框,否则,返回当前页面的边界。

    UIGraphicsAddPDFContextDestinationAtPoint

    [objc]  view plain  copy   void UIGraphicsAddPDFContextDestinationAtPoint(NSString *name, CGPoint point) NS_AVAILABLE_IOS(3_2);   在当前页面创建一个跳转目的地。 name: 跳转连目的地的名称。你分配的名称是本地PDF文档,也是在创建链接到这个目的地时所使用的名字。 point: 当前图形上下文中的一个点。 这个方法在当前页面上标记了一个特定的点来作为跳转的目的地。当用户点击这个链接的时候就会跳转到目的地,这个PDF文档滚动到指定的点可见位置为止。 如果当前的上下文不是一个PDF图形上下文,那么这个方法什么也不做。 这个方法就是设置点击PDF文档中的链接可以跳到某一个位置的,点击区域是 UIGraphicsSetPDFContextDestinationForRect 这个方法设置的,这两个方法的name要统一,但是这个区域的起点在左下角。 [objc]  view plain  copy   例子:点击PDF的(100.00.0200.030.0)这个区域将会跳到PDF的(0, pdfFrame.size.height)这个位置。   UIGraphicsAddPDFContextDestinationAtPoint(@"Chapter12", CGPointMake(0, pdfFrame.size.height));   UIGraphicsSetPDFContextDestinationForRect(@"Chapter12", CGRectMake(100.00.0200.030.0));  

    UIGraphicsSetPDFContextDestinationForRect

    [objc]  view plain  copy   void UIGraphicsSetPDFContextDestinationForRect(NSString *name, CGRect rect) NS_AVAILABLE_IOS(3_2);   链接当前页面上的一个矩形到指定的跳转目的地。 name: 在PDF文档中命名的一个目的地。这个名字和你用 UIGraphicsAddPDFContextDestinationAtPoint 这个方法创建跳转目的地时的名字是一样。 rect: 当前图形上下文中的一个矩形区域 你使用这个方法在PDF文档众创建一个实时的链接。点击PDF文档中指定的区域会使文档显示与跳转目的地相关的内容。 如果当前的上下文不是一个PDF图形上下文,那么这个方法什么也不做。

    UIGraphicsSetPDFContextURLForRect

    [objc]  view plain  copy   void UIGraphicsSetPDFContextURLForRect(NSURL *url, CGRect rect) NS_AVAILABLE_IOS(3_2);   链接当前页面上的矩形区域到指定的URL地址,点击rect区域将会打开url链接。 url: 将要打开的链接。 rect: 当前图形上下文中的一个矩形区域。 你使用这个方法在PDF文档众创建外部的链接。如果指定的这个URL是由不同的App使用的,点击这个矩形框会打开这个App。 如果当前的上下文不是一个PDF图形上下文,那么这个方法什么也不做。 [objc]  view plain  copy   例子:   NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/abc.pdf"];      UIGraphicsBeginPDFContextToFile( path, CGRectZero, nil );      CGRect pdfFrame = CGRectMake(005961842);   UIGraphicsBeginPDFPageWithInfo(pdfFrame, nil);      NSURL *url = [NSURL URLWithString:@"http://blog.csdn.net/lixuwen521/article/details/16879597"];      CGRect textFrame = CGRectMake(101010020);      CGRect linkFrame = textFrame;   linkFrame.origin.y = pdfFrame.size.height - linkFrame.origin.y - linkFrame.size.height;   UIGraphicsSetPDFContextURLForRect(url, linkFrame);   [[UIColor blueColor] setFill];   [@"Chapter1" drawAtPoint:CGPointMake(100.0, pdfFrame.size.height - 30) withFont:[UIFont boldSystemFontOfSize:30.0]];   UIGraphicsAddPDFContextDestinationAtPoint(@"Chapter12", CGPointMake(0, pdfFrame.size.height));   UIGraphicsSetPDFContextDestinationForRect(@"Chapter12", CGRectMake(100.00.0200.030.0));         NSNumber *underline = [NSNumber numberWithInt:NSUnderlineStyleSingle];   NSDictionary *attributesDict = @{NSUnderlineStyleAttributeName:underline, NSForegroundColorAttributeName:[UIColor blueColor]};   NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:@"博客地址" attributes:attributesDict];      [attString drawInRect:textFrame];      UIGraphicsEndPDFContext();  

    String Conversions

    CGAffineTransformFromString

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

    CGPointFromString

    [objc]  view plain  copy   CGPoint CGPointFromString(NSString *string);   把字符串@"{x, y}"转换成CGPoint。

    CGRectFromString

    [objc]  view plain  copy   CGRect CGRectFromString(NSString *string);   把字符串@"{{x, y}, {width, height}}"转换成CGRect。

    CGSizeFromString

    把字符串@"{width, height}"转换成CGSize。

    UIEdgeInsetsFromString

    [objc]  view plain  copy   UIEdgeInsets UIEdgeInsetsFromString(NSString *string);   返回对应于哥顶字符串数据众的UIKit边缘凹凸数据结构。 string: 一个内容为@"{top, left, bottom, right}"结构的字符串。top, left, bottom, right都是 UIedgeInsets 结构体的float类型的组成数据。例如,@”{1.0,2.0,3.0,4.0}”.

    NSStringFromUIOffset

    [objc]  view plain  copy   NSString *NSStringFromUIOffset(UIOffset offset);   把UIOffset(horizontal, vertical)转换成字符串。

    NSStringFromCGAffineTransform

    [objc]  view plain  copy   NSString *NSStringFromCGAffineTransform(CGAffineTransform transform);   把 CGAffineTransform 格式的数据转换成字符串。

    NSStringFromCGPoint

    [objc]  view plain  copy   NSString *NSStringFromCGPoint(CGPoint point);   把CGPoint转换成字符串@"{x, y}".

    NSStringFromCGRect

    [objc]  view plain  copy   NSString *NSStringFromCGSize(CGSize size);   把CGSize转换成字符串@"{width, heigh}".

    NSStringFromCGRect

    [objc]  view plain  copy   NSString *NSStringFromCGRect(CGRect rect);   把CGRect转换成字符串@"{{x, y}, {width, heigh}}".

    NSStringFromUIEdgeInsets

    [objc]  view plain  copy   NSString *NSStringFromUIEdgeInsets(UIEdgeInsets insets);   把UIEdgeInsets转换成字符串。

    NSStringFromUIOffset

    [objc]  view plain  copy   NSString *NSStringFromUIOffset(UIOffset offset);   把UIOffset转换成字符串。

    Managing Edge Insets

    UIEdgeInsets UIEdgeInsetsMake

    [objc]  view plain  copy   UIKIT_STATIC_INLINE UIEdgeInsets UIEdgeInsetsMake(CGFloat top, CGFloat left, CGFloat bottom, CGFloat right) {       UIEdgeInsets insets = {top, left, bottom, right};       return insets;   }   为一个button或者view创建一个边框偏移。 为绘制的矩形区域添加外边距,每一个边都可以有一个不同的值。

    UIEdgeInsetsEqualToEdgeInsets

    [objc]  view plain  copy   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;   }   判断两个UIEdgeInsets是否相同。

    UIEdgeInsetsInsetRect

    [objc]  view plain  copy   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;   }   按照给丁的UIEdgeInsets调整CGRect。

    Managing Offsets

    UIOffsetMake

    [objc]  view plain  copy   UIKIT_STATIC_INLINE UIOffset UIOffsetMake(CGFloat horizontal, CGFloat vertical) {       UIOffset offset = {horizontal, vertical};       return offset;   }   创建UIOffset。

    UIOffsetEqualToOffset

    [objc]  view plain  copy   UIKIT_STATIC_INLINE BOOL UIOffsetEqualToOffset(UIOffset offset1, UIOffset offset2) {       return offset1.horizontal == offset2.horizontal && offset1.vertical == offset2.vertical;   }   判断两个UIOffset是否相等。

    Interface Orientation Macros

    UIInterfaceOrientationIsPortrait

    [objc]  view plain  copy   #define UIInterfaceOrientationIsPortrait(orientation)  ((orientation) == UIInterfaceOrientationPortrait || (orientation) == UIInterfaceOrientationPortraitUpsideDown)   判断当前界面方向是不是竖屏的。 界面方向可以与设备方向不同。你通常使用这个宏在ViewContrller中查看当前界面方向。 Declared In UIApplication.h

    UIInterfaceOrientationIsLandscape

    [objc]  view plain  copy   #define UIInterfaceOrientationIsLandscape(orientation) ((orientation) == UIInterfaceOrientationLandscapeLeft || (orientation) == UIInterfaceOrientationLandscapeRight)   判断界面方向是不是横屏的。用法同 UIInterfaceOrientationIsPortrait 。

    Device Orientation Macros

    UIDeviceOrientationIsValidInterfaceOrientation

    [objc]  view plain  copy   #define UIDeviceOrientationIsValidInterfaceOrientation(orientation) ((orientation) == UIDeviceOrientationPortrait || (orientation) == UIDeviceOrientationPortraitUpsideDown || (orientation) == UIDeviceOrientationLandscapeLeft || (orientation) == UIDeviceOrientationLandscapeRight)   判断设备的转向是否是有效的。 [objc]  view plain  copy   例子:   - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration   {       //先判断是否有效转向       if( UIDeviceOrientationIsValidInterfaceOrientation( toInterfaceOrientation ) )       {    <span style="white-space:pre"> </span>// Do what you want to do....       }   }  

    UIDeviceOrientationIsPortrait

    [objc]  view plain  copy   #define UIDeviceOrientationIsPortrait(orientation)  ((orientation) == UIDeviceOrientationPortrait || (orientation) == UIDeviceOrientationPortraitUpsideDown)   判断设备是不是竖屏的。 Declared  In UIDevice.h.

    UIDeviceOrientationIsLandscape

    [objc]  view plain  copy   #define UIDeviceOrientationIsLandscape(orientation) ((orientation) == UIDeviceOrientationLandscapeLeft || (orientation) == UIDeviceOrientationLandscapeRight)   判断设备是不是横屏的。 Declared  In UIDevice.h.

    Interface Idiom Macro

    UI_USER_INTERFACE_IDIOM

    [objc]  view plain  copy   #define UI_USER_INTERFACE_IDIOM() ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] ? [[UIDevice currentDevice] userInterfaceIdiom] : UIUserInterfaceIdiomPhone)   判断当前设备是否支持 interface idiom。 如果当前设备为iPhone 或者iPod touch,那么userInterfaceIdiom就为UIUserInterfaceIdiomPhone,如果为iPad就为UIUserInterfaceIdiomPad. Declared  In UIDevice.h.

    Accessibility

    UIAccessibilityPostNotification

    [objc]  view plain  copy   void UIAccessibilityPostNotification(UIAccessibilityNotifications notification, id argument);   传递一个消息给辅助的应用。 如果你向要你的用户界面组件流畅的改变或者流畅的出现和消失,那么你的应用或许需要传递辅助性的消息。 Declared In UIAccessibility.h

    UIAccessibilityIsVoiceOverRunning

    [objc]  view plain  copy   BOOL UIAccessibilityIsVoiceOverRunning() NS_AVAILABLE_IOS(4_0);   判断VoiceOver是否打开(运行)。 可以监听 UIAccessibilityVoiceOverStatusChanged 这个消息来判断VoiceOver的状态。 Declared In UIAccessibility.h

    UIAccessibilityIsClosedCaptioningEnabled

    [objc]  view plain  copy   BOOL UIAccessibilityIsClosedCaptioningEnabled() NS_AVAILABLE_IOS(5_0);   判断隐藏式字幕是否可用。 Declared In UIAccessibility.h

    UIAccessibilityRequestGuidedAccessSession

    [objc]  view plain  copy   void UIAccessibilityRequestGuidedAccessSession(BOOL enable, void(^completionHandler)(BOOL didSucceed)) NS_AVAILABLE_IOS(7_0);   通用->辅助功能->引导式访问。 enable: YES是在当前应用程序中把设备设置成单应用模式,NO退出单应用模式。

    completionHandler:

    这个block会通知你的App操作成功还是失败。

    Declared In UIAccessibility.h

    UIAccessibilityIsGuidedAccessEnabled

    [objc]  view plain  copy   BOOL UIAccessibilityIsGuidedAccessEnabled() NS_AVAILABLE_IOS(6_0);   判断引导式访问功能是否可用。

    Declared In UIAccessibility.h

    UIAccessibilityIsInvertColorsEnabled

    [objc]  view plain  copy   BOOL UIAccessibilityIsInvertColorsEnabled() NS_AVAILABLE_IOS(6_0);   判断通用->辅助功能->翻转颜色是否是可用的。 Declared In UIAccessibility.h

    UIAccessibilityIsMonoAudioEnabled

    [objc]  view plain  copy   BOOL UIAccessibilityIsMonoAudioEnabled() NS_AVAILABLE_IOS(5_0);   判断通用->辅助功能->单声道饮品是否是打开的。 Declared In UIAccessibility.h

    UIAccessibilityZoomFocusChanged

    [objc]  view plain  copy   void UIAccessibilityZoomFocusChanged(UIAccessibilityZoomType type, CGRect frame, UIView *view) NS_AVAILABLE_IOS(5_0);   通用->辅助功能->缩放。 通知系统应用程序的焦点改变到了一个新的位置。 type: 聚焦类型。 frame: 在屏幕坐标系中,缩放的框架。 view: 包含缩放框架的view。

    Declared In UIAccessibilityZoom.h

    UIAccessibilityRegisterGestureConflictWithZoom

    [objc]  view plain  copy   void UIAccessibilityRegisterGestureConflictWithZoom() NS_AVAILABLE_IOS(5_0);   如果你的App所使用的多手指手势与系统的缩放手势(用三个手指的)冲突了,调用这个方法来通知用户这个冲突。 Declared In UIAccessibilityZoom.h

    UIAccessibilityConvertFrameToScreenCoordinates

    [objc]  view plain  copy   UIAccessibilityConvertFrameToScreenCoordinates(CGRect rect, UIView *view) NS_AVAILABLE_IOS(7_0);   把指定矩形的视图坐标转换成屏幕坐标系统。

    rect:

    在指定view坐标系中的特定矩形区域。

    view:

    包含特定矩形的view。这个参数不能为nil。

    Declared In UIAccessibility.h

    UIAccessibilityConvertPathToScreenCoordinates

    [objc]  view plain  copy   UIBezierPath *UIAccessibilityConvertPathToScreenCoordinates(UIBezierPath *path, UIView *view) NS_AVAILABLE_IOS(7_0);   把指定的路径对象转换成屏幕坐标系统的并且返回一个有结果的新路径对象。路径样式一样,但是路径上的点是屏幕坐标系的。 path: 你想转换的路径对象。创建路径对象的坐标值应当是相对指定view坐标系统来说的。 这个参数不能为nil. view: 用来定义路径坐标系的view。 这个参数不能为nil. Declared In UIAccessibility.h

    Text Manipulations

    NSTextAlignmentFromCTTextAlignment

    [objc]  view plain  copy   <span style="font-weight: normal;">CTTextAlignment NSTextAlignmentToCTTextAlignment(NSTextAlignment nsTextAlignment);</span>   把一个UIKit 文本对齐常量转换成可以被Core Text使用的与之匹配的常量值。

    nsTextAlignment:

    你想转换测UIKit 文本对齐常量。

    当你需要在UIKit和Core Text对齐常量之间进行映射的时候就调用这个方法。

    Declared In NSText.h。

    NSTextAlignmentToCTTextAlignment

    [objc]  view plain  copy   CTTextAlignment NSTextAlignmentToCTTextAlignment(NSTextAlignment nsTextAlignment);   与 NSTextAlignmentFromCTTextAlignment 相对的方法。 Declared In NSText.h。

    Guided Access Restriction State

    UIGuidedAccessRestrictionStateForIdentifier

    [objc]  view plain  copy   UIGuidedAccessRestrictionState UIGuidedAccessRestrictionStateForIdentifier(NSString *restrictionIdentifier) NS_AVAILABLE_IOS(7_0);   返回指定引导访问限制的限制状态。

    restrictionIdentifier:

    引导访问限制的唯一地标识字符串。

    所有限制的初始化状态为 UIGuidedAccessRestrictionStateAllow.

    Declared In UIGuidedAccessRestrictions.h

    转载请注明原文地址: https://ju.6miu.com/read-11592.html

    最新回复(0)