天天看點

iOS宏(自己使用,持續更新)

iOS宏(自己使用,持續更新)

// 直接從rgb取顔色(rgb 0xff00ff)

#define uicolor_from_rgb(rgbvalue) \

[uicolor colorwithred:((float)((rgbvalue & 0xff0000) >> 16))/255.0 green:((float)((rgbvalue & 0xff00) >> 8))/255.0 blue:((float)(rgbvalue & 0xff))/255.0 alpha:1.0]

//擷取目前螢幕尺寸

#define app_height  [uiscreen mainscreen].applicationframe.size.height

#define scr_height  [uiscreen mainscreen].bounds.size.height

#define scr_width   [uiscreen mainscreen].bounds.size.width

/**

 [宏函數]僅僅執行一回,但裡面有一個for循環,可以執行些其他的操作

 loops --> 循環的次數

 label --> 變量的名字(該變量為static int型号)

 block --> 一個能傳參數進去的block,傳進去的參數為value

 使用示例(僅僅執行一回,但循環4次)

 execute_once_for_some_loops(4, labelname, labelname:^(int value){

 });

 */

#define execute_once_for_some_loops(loops, label, block) \

static int label = 0;\

for(; label < loops; label++){\

block(label);\

}

// 系統子線程池(并發執行)

#define sys_concurrent_queue_h  dispatch_get_global_queue(dispatch_queue_priority_high, 0)

#define sys_concurrent_queue_d  dispatch_get_global_queue(dispatch_queue_priority_default, 0)

#define sys_concurrent_queue_l  dispatch_get_global_queue(dispatch_queue_priority_low, 0)

#define sys_concurrent_queue_b  dispatch_get_global_queue(dispatch_queue_priority_background, 0)

// 系統主線程池(序列執行)

#define sys_serial_queue      dispatch_get_main_queue()

#define sys_ui_queue          dispatch_get_main_queue()

//沙盒路徑

#define sandbox_path        nshomedirectory()