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 ...
随机推荐
- 发展城市 BZOJ 3700
发展城市 [问题描述] 众所周知,Hzwer学长是一名高富帅,他打算投入巨资发展一些小城市. Hzwer打算在城市中开N个宾馆,由于Hzwer非常壕,所以宾馆必须建在空中,但是这样就必须建立宾馆之间的 ...
- [MFC] CFile读写文件实现(高效)
1.文件写入 void CMFCApplication1Dlg::Write() { CFile file; CString FileName = "D:\\100w.txt"; ...
- 使用<sstream> 替代<stdio.h>
c++ 字符串流 sstream(常用于格式转换) 使用stringstream对象简化类型转换C++标准库中的<sstream>提供了比ANSI C的<stdio.h>更 ...
- html的常见meta标签信息
设置页面不缓存<meta http-equiv="pragma" content="no-cache"><meta http-equiv=&q ...
- 转载免费的SSL证书
目前我知道的有2种方式进行免费的SSL证书的获取 第一种:腾讯云申请 第二种:Let's Encrypt (国外在) 我一直使用第一种,还可以,有效期1年. 以下转载第二种: 实战申请Let's En ...
- android控件-images
1.imageButton 图片按钮 <ImageButton android:id="@+id/imageButton" android:layout_width=&quo ...
- 提高google网站访问速度
修改:C:\Windows\System32\drivers\etc\hosts文件 # google websites.203.208.46.180 ssl.gstatic.com203.208.4 ...
- Nginx配置文件语法教程
Nginx的配置文件在一开始可能真的不太好理解,就像当初开始使用Apache那样,像JSON但却不是.可以说是Nginx的一种专门语言,仅为Nginx服务的. 市面上基本都是写了一点不写一点的教程,基 ...
- DELPHI方法注释的标准写法
/// <summary> /// 查询数据 /// </summary> /// <param name="accountno">帐套号< ...
- Go -- PipleLine
1.pipeline的产生 从一个现象说起,有一家咖啡吧生意特别好,每天来的客人络绎不绝,客人A来到柜台,客人B紧随其后,客人C排在客人B后面,客人D排在客人C后面,客人E排在客人D后面,一直排到店面 ...