IOS开发之常用系统函数收集

来源:互联网 发布:国内经济数据库 编辑:程序博客网 时间:2024/05/03 09:43

字符串相关

  •  NSString 的函数 sizeWithFont:constrainedToSize:lineBreakMode

      API文档解释:若字符串以规定的约束条件进行描绘,则返回实际的大小。

      用途:返回以指定字体进行描绘时,字符串所占据的实际大小。

      举例:

        

UIFont *font = [UIFont systemFontOfSize:12]; 
CGSize size = [text sizeWithFont:font constrainedToSize:CGSizeMake(150.0f, 1000.0f) lineBreakMode:UILineBreakModeCharacterWrap];

       说明:获取字符串在指定的size内(宽度超过150,则换行)所需的的实际高度和宽度.

 NSDate

日期之间比较可用以下方法 

    - (BOOL)isEqualToDate:(NSDate *)otherDate;

    与otherDate比较,相同返回YES

 

    - (NSDate *)earlierDate:(NSDate *)anotherDate;

    与anotherDate比较,返回较早的那个日期

 

    - (NSDate *)laterDate:(NSDate *)anotherDate;

    与anotherDate比较,返回较晚的那个日期

 

    - (NSComparisonResult)compare:(NSDate *)other;

    该方法用于排序时调用:

      . 当实例保存的日期值与anotherDate相同时返回NSOrderedSame

      . 当实例保存的日期值晚于anotherDate时返回NSOrderedDescending

      . 当实例保存的日期值早于anotherDate时返回NSOrderedAscending


UI相关

 

CGRectIntersectsRect

bool CGRectIntersectsRect (CGRect rect1,CGRect rect2);

作用:判断两个矩形是否相交。


原创粉丝点击