IOS开发,知识点小结,ios开发中经常使用的宏定义总结
IOS开发,从应用跳转到用浏览器打开网页:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.oatos.com/bbs/"]];
用一个Button覆盖整个cell,加入动作
cell.accessoryType = UITableViewCellAccessoryNone;
UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0.0, 0.0, cell.contentView.frame.size.width, 54.0)];
btn.autoresizingMask = UIViewAutoresizingFlexibleWidth;
btn.backgroundColor = COLOR(243.0, 89.0, 31.0, 1.0);
btn.tag = 1003;
NSString *title = nil;
#ifndef appstore
title = NSLocalizedString(@"Pad_setting_exitBtnTitle", nil);
#else
title = NSLocalizedString(@"Pad_setting_logoutBtnTitle", nil);
#endif
[btn setBackgroundImage:[UIImage imageNamed:@"bgBtnLogoutNormal.png"] forState:UIControlStateNormal];
[btn setBackgroundImage:[UIImage imageNamed:@"bgBtnLogoutHover.png"] forState:UIControlStateHighlighted];
[btn setTitle:title forState:UIControlStateNormal];
btn.titleLabel.font = [UIFont boldSystemFontOfSize:20.0];
[btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(loginOuBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:btn];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
经常使用的宏定义
#define IOS_VERSION [[UIDevice currentDevice] deviceVersion]
#define kDeviceAgent [[UIDevice currentDevice] deviceAgent] #define IsiOS7Later !(IOS_VERSION < 7.0)
#define Is4Inch [OatosUtils is4InchScreen]
#define COLOR(R,G,B,A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]
#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]
#define Size(w, h) CGSizeMake(w, h)
#define Point(x, y) CGPointMake(x, y)
#define Rect(x, y, w, h) CGRectMake(x, y, w, h)
#define ViewWidth(v) v.frame.size.width
#define ViewHeight(v) (IsiOS7Later ? v.frame.size.height : v.frame.size.height - StatusBarHeight)
#define ViewX(v) v.frame.origin.x
#define ViewY(v) v.frame.origin.y
#define ViewRect(v) Rect(ViewX(v), ViewY(v), ViewWidth(v), ViewHeight(v))
#define SelfViewHeight self.view.bounds.size.height
#define kDeviceScreenH [[UIScreen mainScreen] bounds].size.height
#define kDeviceScreenW [[UIScreen mainScreen] bounds].size.width #define kAppMainScreenFrameWidth [[UIScreen mainScreen] applicationFrame].size.width
#define kAppMainScreenFrameHeight [[UIScreen mainScreen] applicationFrame].size.height
#define StatusBarHeight [UIApplication sharedApplication].statusBarFrame.size.height #define kHeightStatusAndNav (IsiOS7Later ? 64 : 44) // 状态栏和导航栏的总高度
#define kPadHeightNavForPopView 44 //3.4版本号后開始使用的,重构后机制不一样(跟弹出层布局相关)
#define kStatusBarFix (IsiOS7Later ? 20 : 0) // 状态栏高度
#define kPadHeightStatusAndNav (IsiOS7Later ? 64 : 0) // 状态栏和导航栏的总高度
#define kPadNaviBarHeight (IsiOS7Later ? 54.0f : 0) // pad不含状态栏的导航栏的高度
#define kPadBottomBarHeight 60.0f
#define kPadHeightNav (IsiOS7Later ? 44 : 0)
小结:代码中,尽量不要用写死的数据,不然版本号适配以及以后的优化是非常痛苦的事情。
还实用宏定义能够简化代码。眼下我的理解仅仅有这么多。希望以后对这个掌握的更好。尽管这仅仅是小基础。可是也是一种良好的编程习惯。一个好的開始。
IOS开发,知识点小结,ios开发中经常使用的宏定义总结的更多相关文章
- iOS --- 总结Objective-C中经常使用的宏定义(持续更新中)
将iOS开发中经常使用的宏定义整理例如以下,仅包括Objective-C. 而对于Swift,不能使用宏,则能够定义全局函数或者extension.请參考博客iOS - 总结Swift中经常使用的全局 ...
- C中的预编译宏定义
可以用宏判断是否为ARC环境 #if _has_feature(objc_arc) #else //MRC #endif C中的预编译宏定义 -- 作者: infobillows 来源:网络 在将一 ...
- IOS开发中经常使用的宏定义
ios讨论群1群:135718460 有些时候.我们须要将代码简洁化,这样便于读代码.我们能够将一些不变的东东抽取出来.将变化的东西作为參数. 定义为宏,这样在写的时候就简单多了. 以下例举了一些经常 ...
- VC中预处理指令与宏定义详解
刚接触到MFC编程的人往往会被MFC 向导生成的各种宏定义和预处理指令所吓倒,但是预处理和宏定义又是C语言的一个强大工具.使用它们可以进行简单的源代码控制,版本控制,预警或者完成一些特殊的功能. 一个 ...
- 在oc中一些常用的宏定义总结
1.打印CGRect,Size,Point #define NSLogRect(rect) NSLog(@"%s x:%.4f, y:%.4f, w:%.4f, h:%.4f", ...
- linux中offsetof与container_of宏定义
linux内核中offsetof与container_of的宏定义 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->M ...
- C++ 中 #ifndef, #define, #endif 宏定义
目的:为了保证包含的内容只被程序(include) 和编译了一次.判断预处理器常量是否已被定义. 预编译将所有头文件(#include"XXX.h")用头文件中的内容来替换,头文件 ...
- 内核中likely和unlikely宏定义
在内核代码中经常会看到unlikely和likely的踪影.他们实际上是定义在 linux/compiler.h 中的两个宏. #define likely(x) __builtin_expec ...
- iOS开发中常用到的宏定义
1.首次启动判断: #define First_Launched @"firstLaunch" 2.ios7系统判断: #define IsIOS7 ([[[UIDevice cu ...
随机推荐
- 【java小工具】从.java文件中筛选出方法,并计算出方法在这些文件中出现的次数
package getMethod; import java.io.*; import java.util.*; import java.util.regex.Matcher; import java ...
- Myeclipse 2014 for mac10.9 激活
网上查了N多激活,都无法正确激活.后来慢慢爬文,终于激活了...真艰难啊. 所以怒马一份! 安装myeclipse. 安装完成别急着打开. 在终端里面打开的破解文件jar. java -jar ...
- (44)C#网络2
一.用SmtpClient类发送邮件 允许应用程序使用简单邮件传输协议 (SMTP) 发送电子邮件 using System.Net.Mail; SmtpClient smtpClient = new ...
- 多语言业务错误日志收集监控工具Sentry 安装与使用
Sentry 是一个实时事件日志记录和汇集的平台.其专注于错误监控以及提取一切事后处理所需信息而不依赖于麻烦的用户反馈. Sentry是一个日志平台, 它分为客户端和服务端,客户端(目前客户端有Pyt ...
- Struts2的值栈和OGNL牛逼啊
Struts2的值栈和OGNL牛逼啊 一 值栈简介: 值栈是对应每个请求对象的一套内存数据的封装,Struts2会给每个请求创建一个新的值栈,值栈能够线程安全的为每个请求提供公共的数据存取服务. 二 ...
- T2639 约会计划 codevs
http://codevs.cn/problem/2639/ 题目描述 Description cc是个超级帅哥,口才又好,rp极高(这句话似乎降rp),又非常的幽默,所以很多mm都跟他关系不错.然而 ...
- [Bzoj5254][Fjwc2018]红绿灯(线段树)
5254: [Fjwc2018]红绿灯 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 31 Solved: 24[Submit][Status][D ...
- Servlet(生命周期)
<?xml version="1.0" encoding="UTF-8"?> <web-app version="3.0" ...
- Windows下Python安装pyecharts
都说pyechart用来可视化好,可是安装的时候各种坑 正常情况是 pip install pyecharts 然后各种报错,找到一种可行的方式 在https://pypi.org/project/p ...
- 一道题目- Find the smallest range that includes at least one number from each of the k lists
You have k lists of sorted integers. Find the smallest range that includes at least one number from ...