一些小方法

2021-07-03 06:10:37 字數 1712 閱讀 6118

1、將六位的顏色碼轉換成紅綠藍三色

+ (uicolor *)getcolor:(nsstring *)hexcolor

2、計算根據字串長度計算空間的size

nsstring *title =@「苦澀奉公克己惡毒啦沒考慮到呢離開電腦礦務局恩看到今年份渴望能看見你哭呢」;

cgsize sizeh =[title boundingrectwithsize:cgsizemake(_basecontent.frame.size.width-65, maxfloat) options:nsstringdrawinguseslinefragmentorigin     attributes:@ context:nil].size;

(如果要高度或者寬度時,cgsize 改為cgfloat 並且在最後size後面加上 .height 或者 .width)

3、清空歸檔資料

//歸檔檔案位址

nsstring *filepath = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) objectatindex:0];  

nsfilemanager *manager = [nsfilemanager defaultmanager];

nserror *error;

[manager removeitematpath:filepath error:&error];

4、通知傳值

//發出通知 並將courseware的值「季節」傳出去

[[nsnotificationcenter defaultcenter]postnotificationname:@"select" object:nil userinfo:@];

//接受通知

[[nsnotificationcenter defaultcenter]addobserver:self selector:@selector(click:) name:@"select" object:nil];

//讀取傳遞得值

-(void)click:(nsnotification*)fee{

nsdictionary *dic=[fee userinfo];

nsstring *et=dic[@"coursewaretype"]

5、動畫

[uiview animatewithduration:0.5 animations:^{

動作}];

如果想讓乙個動作有動畫效果就將**寫入其中,0.5是動畫的完成的時間

6、新增子控制器

UItableView一些小方法

1 uitableview設定偏移量 通過設定tableview的偏移量,讓列表預設滾動到某個位置,內涵段子裡面的效果 mytableview setcontentoffset cgpointmake 0,100 animated yes 有時候只需要重新整理某行的cell的資料,完全沒必要呼叫 t...

一些小方法 持續更新

我在寫指令碼的時候,會有些自己常用的方法,這兒做個分享 個人部落格 def date list self,start date,end date 傳開始 結束日期,返回兩者之間所有日期的list param start date 開始日期 param end date 結束日期 return 2者之...

一些ArrayList的一些小方法

1 arraylist的一些小方法 加入某本圖書 list.add bk5 檢視是否包含某本圖書 boolean a list.contains bk1 system.out.println a 刪除某本圖書 list.remove bk5 根據圖書名檢視,刪除該圖書 集合的下角標是從0開始的 fo...