iOS 常用方法的宏

由于在项目经常需要用到一些方法,每次都写那么长一串比较麻烦,所以就写了一个.h文件,定义了一些常用方法的宏:


文件名:UtilityMacro.h

//
//  UtilityMacro.h
//  UtilityClass
//
//  Created by mrj on 12-7-8.
//  Copyright (c) 2013年 极致. All rights reserved.
//

#ifndef UtilityClass_Macro_h
#define UtilityClass_Macro_h

#define ALog(fmt,...) NSLog((@"ALog: %s [Line %d] \n" fmt), __PRETTY_FUNCTION__, __LINE__,##__VA_ARGS__);

#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )

#define FLOG(str, args...) NSLog\
(@"[文件:%s] [行号:%d] [类:%@] [方法:%s]\n%@", strrchr(__FILE__, '/'), __LINE__, [self class], sel_getName(_cmd),\
[NSString stringWithFormat:str , ##args ])


#define FASSERT(condition, str, args...) NSAssert\
(condition, @"--------------------------------------------------------------------------------\
\n[文件:%s] [行号:%d] [类:%@] [方法:%s]\n%@", strrchr(__FILE__, '/'), __LINE__, [self class], sel_getName(_cmd),\
[NSString stringWithFormat:str , ##args ])


#define ResourcePath     [[NSBundle mainBundle] resourcePath]    //获取自定义文件的bundle路径
#define ImageNamed(name) [UIImage imageWithContentsOfFile:[ResourcePath stringByAppendingPathComponent:name]]
#define RGBCOLOR(r,g,b)  [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]    //RGB进制颜色值
#define HexColor(hexValue) [UIColor colorWithRed:((float)((hexValue & 0xFF0000) >> 16))/255.0 green:((float)((hexValue & 0xFF00) >> 8))/255.0 blue:((float)(hexValue & 0xFF))/255.0 alpha:1.0]   //16进制颜色值,如:#000000 , 注意:在使用的时候hexValue写成:0x000000

#endif


需要使用的时候把它写入到:Supporting Files ---> *-Prefix.pch文件里面(示例如下):

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
    #import "UtilityMacro.h"
    #import "NotificationName.h"
#endif


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值