api文件解釋:若字串以規定的約束條件進行描繪,則返回實際的大小。
用途:返回以指定字型進行描繪時,字串所佔據的實際大小。
舉例:
uifont *font = [uifont systemfontofsize:12];
cgsize size = [text sizewithfont:font constrainedtosize:cgsizemake(150.0f, 1000.0f) linebreakmode:uilinebreakmodecharacterwrap];
說明:獲取字串在指定的size內(寬度超過150,則換行)所需的的實際高度和寬度.
日期之間比較可用以下方法
- (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
cgrectintersectsrect
bool cgrectintersectsrect (cgrect rect1,cgrect rect2);
作用:判斷兩個矩形是否相交。
iOS開發常用函式
1 三角函式 double sin double 正弦 double cos double 余弦 double tan double 正切 2 反三角函式 double asin double 結果介於 pi 2,pi 2 double acos double 結果介於 0,pi double at...
IOS開發之 常用函式和常數
介紹一下objective c常用的函式,常數變數 算術函式 算術函式 函式名說明int rand 隨機數生成。例 srand time nil 隨機數初期化 int val rand p 0 49之間的隨機數 int abs int a 整數的絕對值 例 int val abs 8 8 浮點數的時...
IOS開發之 常用函式和常數
介紹一下objective c常用的函式,常數變數 算術函式 函式名說明int rand 隨機數生成。例 srand time nil 隨機數初期化 int val rand p 0 49之間的隨機數 int abs int a 整數的絕對值 例 int val abs 8 8 浮點數的時候用fab...