iOS 小技巧笔记(持续更新)

[UIApplication sharedApplication].applicationIconBadgeNumber = 0; // 清空 App 图标的未读推送消息个数


#define RGB(A, B, C)  [UIColor colorWithRed:A/255.0 green:B/255.0 blue:C/255.0 alpha:1.0]    // 自定义 RGB 颜色
#define kScreenWidth  [UIScreen mainScreen].bounds.size.width    // 屏幕宽度 
#define kScreenHeight [UIScreen mainScreen].bounds.size.height   // 屏幕高度
// 只在 Debug 下,打印 Log
#ifdef DEBUG
#define debugLog(...) NSLog(__VA_ARGS__)
#define debugMethod() NSLog(@"%s", __func__)
#else
#define debugLog(...)
#define debugMetohd()
#endif
#define is_iPhone       (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)        // 判断 iPhone
#define is_iPad         (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)          // 判断 iPad
#define is_AppleTV      (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomTV)           // 判断 AppleTV
#define is_CarPlay      (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomCarPlay)      // 判断 CarPlay
#define is_Unspecified  (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomUnspecified)  // 判断 未知设备

计算

// 四舍五入
extern float roundf(float);
extern double round(double);
extern long double roundl(long double);
// 向下取整
extern float floorf(float);
extern double floor(double);
extern long double floorl(long double);

// 向上取整
extern float ceilf(float);
extern double ceil(double);
extern long double ceill(long double);

显示

self.automaticallyAdjustsScrollViewInsets = NO; // 自动设置内边距,默认为 YES






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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值