常用宏

//屏幕寬度:#define kSCREENWIDTH ? [[UIScreen mainScreen] bounds].size.width

//屏幕高度:#define kSCREENHEIGHT ? [[UIScreen mainScreen] bounds].size.height

//屏幕尺寸:#define WINSIZE [[UIScreen mainScreen] bounds].size

程序更新:[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"程序地址"]]

//圖片名獲取圖片:#define IMG(name) [UIImage imageNamed:name]

//獲取系統(tǒng)版本

#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]

#define CurrentSystemVersion [[UIDevice currentDevice] systemVersion]

#define isIOS4 ([[[UIDevice currentDevice] systemVersion] intValue]==4)

#define isIOS5 ([[[UIDevice currentDevice] systemVersion] intValue]==5)

#define isIOS6 ([[[UIDevice currentDevice] systemVersion] intValue]==6)

#define isIOS7 ([[[UIDevice currentDevice] systemVersion] intValue]==7)

#define isIOS8 ([[[UIDevice currentDevice] systemVersion] intValue]==8)

#define isIOS9 ([[[UIDevice currentDevice] systemVersion] intValue]==9)

#define isIOS10 ([[[UIDevice currentDevice] systemVersion] intValue]==10)

#define isAfterIOS4 ([[[UIDevice currentDevice] systemVersion] intValue]>4)

#define isAfterIOS5 ([[[UIDevice currentDevice] systemVersion] intValue]>5)

#define isAfterIOS6 ([[[UIDevice currentDevice] systemVersion] intValue]>6)

#define isAfterIOS7 ([[[UIDevice currentDevice] systemVersion] intValue]>7)

#define isAfterIOS8 ([[[UIDevice currentDevice] systemVersion] intValue]>8)

本地地址:#define UserInfoFilePath [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject] stringByAppendingPathComponent:@"本地文件名"]

//-------------------打印日志-------------------------

//DEBUG ?模式下打印日志,當(dāng)前行

#ifdef DEBUG

# ? define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);

#else

# ? define DLog(...)

#endif

//重寫NSLog,Debug模式下打印日志和當(dāng)前行數(shù)

#if DEBUG

#define NSLog(FORMAT, ...) fprintf(stderr,"\\nfunction:%s line:%d content:%s\\n", __FUNCTION__, __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);

#else

#define NSLog(FORMAT, ...) nil

#endif

//獲取系統(tǒng)版本

#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]

#define CurrentSystemVersion [[UIDevice currentDevice] systemVersion]

//判斷是真機(jī)還是模擬器

#if TARGET_OS_IPHONE

//iPhone Device

#endif

#if TARGET_IPHONE_SIMULATOR

//iPhone Simulator

#endif

//讀取本地圖片

#define LOADIMAGE(file,ext) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:file ofType:ext]]

//定義UIImage對象

#define IMAGE(A) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:A ofType:nil]]

//----------------------顏色類---------------------------

// rgb顏色轉(zhuǎn)換(16進(jìn)制->10進(jìn)制)

#define UIColorFromRGB(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]

//帶有RGBA的顏色設(shè)置

#define COLOR(R, G, B, A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]

// 獲取RGB顏色

#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]

#define RGB(r,g,b) RGBA(r,g,b,1.0f)

//背景色

#define BACKGROUND_COLOR [UIColor colorWithRed:242.0/255.0 green:236.0/255.0 blue:231.0/255.0 alpha:1.0]

//清除背景色

#define CLEARCOLOR [UIColor clearColor]

//定義一個API

#define APIURL ? ? ? ? ? ? ? ?@"http://xxxxx/"

//登陸API

#define APILogin ? ? ? ? ? ? ?[APIURL stringByAppendingString:@"Login"]

//G-C-D

#define BACK(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)

#define MAIN(block) dispatch_async(dispatch_get_main_queue(),block)

//NSUserDefaults 實例化

#define USER_DEFAULT [NSUserDefaults standardUserDefaults]

//單例化一個類

#define SYNTHESIZE_SINGLETON_FOR_CLASS(classname) \\

\\

static classname *shared##classname = nil; \\

\\

+ (classname *)shared##classname \\

{ \\

@synchronized(self) \\

{ \\

if (shared##classname == nil) \\

{ \\

shared##classname = [[self alloc] init]; \\

} \\

} \\

\\

return shared##classname; \\

} \\

\\

+ (id)allocWithZone:(NSZone *)zone \\

{ \\

@synchronized(self) \\

{ \\

if (shared##classname == nil) \\

{ \\

shared##classname = [super allocWithZone:zone]; \\

return shared##classname; \\

} \\

} \\

\\

return nil; \\

} \\

\\

- (id)copyWithZone:(NSZone *)zone \\

{ \\

return self; \\

}

#endif

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子嫌术,更是在濱河造成了極大的恐慌讲衫,老刑警劉巖浩蓉,帶你破解...
    沈念sama閱讀 222,590評論 6 517
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件础钠,死亡現(xiàn)場離奇詭異浩峡,居然都是意外死亡顽悼,警方通過查閱死者的電腦和手機(jī)曼振,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,157評論 3 399
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來蔚龙,“玉大人冰评,你說我怎么就攤上這事∧靖” “怎么了甲雅?”我有些...
    開封第一講書人閱讀 169,301評論 0 362
  • 文/不壞的土叔 我叫張陵,是天一觀的道長坑填。 經(jīng)常有香客問我抛人,道長,這世上最難降的妖魔是什么脐瑰? 我笑而不...
    開封第一講書人閱讀 60,078評論 1 300
  • 正文 為了忘掉前任妖枚,我火速辦了婚禮,結(jié)果婚禮上苍在,老公的妹妹穿的比我還像新娘绝页。我一直安慰自己荠商,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 69,082評論 6 398
  • 文/花漫 我一把揭開白布续誉。 她就那樣靜靜地躺著莱没,像睡著了一般。 火紅的嫁衣襯著肌膚如雪酷鸦。 梳的紋絲不亂的頭發(fā)上饰躲,一...
    開封第一講書人閱讀 52,682評論 1 312
  • 那天,我揣著相機(jī)與錄音臼隔,去河邊找鬼嘹裂。 笑死,一個胖子當(dāng)著我的面吹牛摔握,可吹牛的內(nèi)容都是我干的焦蘑。 我是一名探鬼主播,決...
    沈念sama閱讀 41,155評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼盒发,長吁一口氣:“原來是場噩夢啊……” “哼例嘱!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起宁舰,我...
    開封第一講書人閱讀 40,098評論 0 277
  • 序言:老撾萬榮一對情侶失蹤拼卵,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后蛮艰,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體腋腮,經(jīng)...
    沈念sama閱讀 46,638評論 1 319
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,701評論 3 342
  • 正文 我和宋清朗相戀三年壤蚜,在試婚紗的時候發(fā)現(xiàn)自己被綠了即寡。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,852評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡袜刷,死狀恐怖聪富,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情著蟹,我是刑警寧澤墩蔓,帶...
    沈念sama閱讀 36,520評論 5 351
  • 正文 年R本政府宣布,位于F島的核電站萧豆,受9級特大地震影響奸披,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜涮雷,卻給世界環(huán)境...
    茶點故事閱讀 42,181評論 3 335
  • 文/蒙蒙 一阵面、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦样刷、人聲如沸嗽交。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,674評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至拾枣,卻和暖如春沃疮,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背梅肤。 一陣腳步聲響...
    開封第一講書人閱讀 33,788評論 1 274
  • 我被黑心中介騙來泰國打工司蔬, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人姨蝴。 一個月前我還...
    沈念sama閱讀 49,279評論 3 379
  • 正文 我出身青樓俊啼,卻偏偏與公主長得像,于是被迫代替她去往敵國和親左医。 傳聞我的和親對象是個殘疾皇子授帕,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,851評論 2 361

推薦閱讀更多精彩內(nèi)容

  • iOS開發(fā)過程中,使用的一些常用宏定義 字符串是否為空#define kStringIsEmpty(str) ([...
    goyohol閱讀 5,362評論 30 85
  • ifndef MacroDefinition_h define MacroDefinition_h //-----...
    灰客閱讀 366評論 0 0
  • //AppDelegate #define APPDELEGATE [(AppDelegate*)[UIAppli...
    __life__閱讀 324評論 1 0
  • 思之浮梢,念之 卻不可及 文字跛十,是唯一 能夠觸摸到你的方式 春雨 細(xì)碎而又柔軟 滲透著一絲清涼 柔軟的柳條 吐出一簇簇...
    游游茶舍閱讀 316評論 0 1
  • 至今高考后兩個多月過去了在這個兩個多月時間里同學(xué)們都紛紛周游全國在空間朋友圈曬著精美無比的照片又有同學(xué)找到兼職可以...
    清悅橙閱讀 655評論 3 1