iOS 開發:獲取狀態欄、導航欄、tabBar 的高度

https://blog.stormbirds.cn/articles/2019/12/17/1576569283226.html

状态栏、导航栏 和 tabbar 高度(pt)

iPhone型号状态栏状态栏导航栏导航栏tabBartabBar
iPhone型号竖屏横屏竖屏横屏竖屏横屏
5s/SE/6/6s/7/8(iOS10)202044324949
5s/SE/6/6s/7/8(iOS11)202044324932
6/6s/7/8 Plus202044444949
X/XS440443283(49+34)53(32+21)
XR/XS Max440444483(49+34)70(49+21)

(对于原生TabBar,iPhoneX会在其底部增加34pt,为的是不影响所谓的HomeBar,从而整个TabBar的高度变为49+34=83pt)

bar高度总结
状态栏全面屏iPhone竖屏44,全面屏iPhone横屏0,普通iPhone为20
导航栏屏幕宽度小于400的设备横屏时为32,其余情况为44
tabbar屏幕宽度小于400的设备在iOS11以上的系统横屏时为32,其余情况为49
安全区域竖屏34,横屏21
iPad型号状态栏导航栏tabBar
普通iPad(iOS11)204449
普通iPad(iOS12)205050
全面屏iPad245065(50+15)

获取状态栏、导航栏、tabBar高度

//获取状态栏的高度
CGFloat statusHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
NSLog(@"状态栏高度:%f",statusHeight);

//获取导航栏的高度
CGFloat navHeight = self.navigationController.navigationBar.frame.size.height;
NSLog(@"导航栏高度:%f",navHeight);

//获取tabBar的高度
//1.在tabBarController中使用(你的继承自UITabBarController的VC)
CGFloat tabBarHeight = self.tabBar.frame.size.height;
NSLog(@"tabBar高度:%f",tabBarHeight);
//2.在非tabBarController中使用
UITabBarController *tabBarVC = [[UITabBarController alloc] init];//(这儿取你当前tabBarVC的实例)
CGFloat tabBarHeight = tabBarVC.tabBar.frame.size.height;
NSLog(@"tabBar高度:%f",tabBarHeight); 

定义状态栏、导航栏、tabBar高度

#define kIs_iphone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define kIs_iPhoneX kScreenWidth >=375.0f && kScreenHeight >=812.0f&& kIs_iphone
    
/*状态栏高度*/
#define kStatusBarHeight (CGFloat)(kIs_iPhoneX?(44.0):(20.0))
/*导航栏高度*/
#define kNavBarHeight (44)
/*状态栏和导航栏总高度*/
#define kNavBarAndStatusBarHeight (CGFloat)(kIs_iPhoneX?(88.0):(64.0))
/*TabBar高度*/
#define kTabBarHeight (CGFloat)(kIs_iPhoneX?(49.0 + 34.0):(49.0))
/*顶部安全区域远离高度*/
#define kTopBarSafeHeight (CGFloat)(kIs_iPhoneX?(44.0):(0))
 /*底部安全区域远离高度*/
#define kBottomSafeHeight (CGFloat)(kIs_iPhoneX?(34.0):(0))
/*iPhoneX的状态栏高度差值*/
#define kTopBarDifHeight (CGFloat)(kIs_iPhoneX?(24.0):(0))
/*导航条和Tabbar总高度*/
#define kNavAndTabHeight (kNavBarAndStatusBarHeight + kTabBarHeight)


还在用宏定义 “iphoneX” 判断安全区域 (safe area) 吗? 下文教學改用 Safe Area

https://www.jianshu.com/p/5bebc28e0ede


<iOS螢幕適配> iPhoneX SafeArea - 安全區域 宏定义

https://www.itread01.com/content/1541935567.html

/** 裝置螢幕寬度 */

#define LCLScreenWidth [[UIScreen mainScreen] bounds].size.width

/** 裝置螢幕高度 */

#define LCLScreenHeight [[UIScreen mainScreen] bounds].size.height

/** iPhoneX判斷 */

#define LCLIsIphoneX (CGSizeEqualToSize(CGSizeMake(375.f, 812.f), [UIScreen mainScreen].bounds.size) || CGSizeEqualToSize(CGSizeMake(812.f, 375.f), [UIScreen mainScreen].bounds.size))

/** 狀態列高度 */

#define LCL_StatusBar_Height ((LCLIsIphoneX) ? 44 : 20)

/** 導航欄高度 */

#define LCL_NavBar_Height ((LCLIsIphoneX) ? 88 : 64)

/** 標籤欄高度 */

#define LCL_TabBar_Height ((LCLIsIphoneX) ? 83 : 49)

/** 底部橫條高度 */

#define LCL_HomeIndicator_Height ((LCLIsIphoneX) ? 34 : 0)


https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/605821/

適配iPhone X相關的坑,總的來說有兩類坑,一個是導航欄+狀態列的高度發生了變化,一個是一些沒有實現實現-tableView: viewForHeaderInSection:和-tableView: viewForFooterInSection:等代理方法的UITableView會出錯位的問題。




iOS 開發:導航欄顯示和隱藏的坑

混合使用 UINavigationController 和 UITabBarController 後,

如果有些畫面需要隱藏『導航欄』,而有些畫面又需要顯示『導航欄』,

動畫切換過程的瑕疵,如何解決:

https://www.itread01.com/content/1550558164.html



隱私政策 (最簡化版)

1. Mobile app

2. 發布者身分是個人

3. 應用名稱是『壞寶寶學中文』

4. App 沒有收集使用者的個人資訊和位置資訊

5. App 沒有利用任何工具分析使用者的行為

6. How can users contact you for any questions regarding your privacy policy? => by email

7. Free Privacy Policy (不包含 International Privacy Policy 或 GDPR Privacy Policy 等等)




Privacy Policy

Effective date: October 02, 2020

壞寶寶學中文 ("us", "we", or "our") operates the 壞寶寶學中文 mobile application (hereinafter referred to as the "Service").

This page informs you of our policies regarding the collection, use and disclosure of personal data when you use our Service and the choices you have associated with that data.

We use your data to provide and improve the Service. By using the Service, you agree to the collection and use of information in accordance with this policy. Unless otherwise defined in this Privacy Policy, the terms used in this Privacy Policy have the same meanings as in our Terms and Conditions.

Definitions

  • Service

    Service is the 壞寶寶學中文 mobile application operated by 壞寶寶學中文

  • Personal Data

    Personal Data means data about a living individual who can be identified from those data (or from those and other information either in our possession or likely to come into our possession).

  • Usage Data

    Usage Data is data collected automatically either generated by the use of the Service or from the Service infrastructure itself (for example, the duration of a page visit).

  • Cookies

    Cookies are small files stored on your device (computer or mobile device).

Information Collection and Use

We collect several different types of information for various purposes to provide and improve our Service to you.

Types of Data Collected

Personal Data

While using our Service, we may ask you to provide us with certain personally identifiable information that can be used to contact or identify you ("Personal Data"). Personally identifiable information may include, but is not limited to:

  • Cookies and Usage Data

Usage Data

When you access the Service with a mobile device, we may collect certain information automatically, including, but not limited to, the type of mobile device you use, your mobile device unique ID, the IP address of your mobile device, your mobile operating system, the type of mobile Internet browser you use, unique device identifiers and other diagnostic data ("Usage Data").

Tracking & Cookies Data

We use cookies and similar tracking technologies to track the activity on our Service and we hold certain information. Cookies are files with a small amount of data which may include an anonymous unique identifier. Cookies are sent to your browser from a website and stored on your device. Other tracking technologies are also used such as beacons, tags and scripts to collect and track information and to improve and analyse our Service. You can instruct your browser to refuse all cookies or to indicate when a cookie is being sent. However, if you do not accept cookies, you may not be able to use some portions of our Service. Examples of Cookies we use:

  • Session Cookies. We use Session Cookies to operate our Service.
  • Preference Cookies. We use Preference Cookies to remember your preferences and various settings.
  • Security Cookies. We use Security Cookies for security purposes.

Use of Data

壞寶寶學中文 uses the collected data for various purposes:

  • To provide and maintain our Service
  • To notify you about changes to our Service
  • To allow you to participate in interactive features of our Service when you choose to do so
  • To provide customer support
  • To gather analysis or valuable information so that we can improve our Service
  • To monitor the usage of our Service
  • To detect, prevent and address technical issues

Transfer of Data

Your information, including Personal Data, may be transferred to - and maintained on - computers located outside of your state, province, country or other governmental jurisdiction where the data protection laws may differ from those of your jurisdiction.

If you are located outside and choose to provide information to us, please note that we transfer the data, including Personal Data, to and process it there.

Your consent to this Privacy Policy followed by your submission of such information represents your agreement to that transfer.

壞寶寶學中文 will take all the steps reasonably necessary to ensure that your data is treated securely and in accordance with this Privacy Policy and no transfer of your Personal Data will take place to an organisation or a country unless there are adequate controls in place including the security of your data and other personal information.

Disclosure of Data

Legal Requirements

壞寶寶學中文 may disclose your Personal Data in the good faith belief that such action is necessary to:

  • To comply with a legal obligation
  • To protect and defend the rights or property of 壞寶寶學中文
  • To prevent or investigate possible wrongdoing in connection with the Service
  • To protect the personal safety of users of the Service or the public
  • To protect against legal liability

Security of Data

The security of your data is important to us but remember that no method of transmission over the Internet or method of electronic storage is 100% secure. While we strive to use commercially acceptable means to protect your Personal Data, we cannot guarantee its absolute security.

Service Providers

We may employ third party companies and individuals to facilitate our Service ("Service Providers"), provide the Service on our behalf, perform Service-related services or assist us in analysing how our Service is used. These third parties have access to your Personal Data only to perform these tasks on our behalf and are obligated not to disclose or use it for any other purpose.

Links to Other Sites

Our Service may contain links to other sites that are not operated by us. If you click a third party link, you will be directed to that third party's site. We strongly advise you to review the Privacy Policy of every site you visit. We have no control over and assume no responsibility for the content, privacy policies or practices of any third party sites or services.

Children's Privacy

Our Service does not address anyone under the age of 18 ("Children").

We do not knowingly collect personally identifiable information from anyone under the age of 18.

Changes to This Privacy Policy

We may update our Privacy Policy from time to time. We will notify you of any changes by posting the new Privacy Policy on this page. We will let you know via a prominent notice on our Service, prior to the change becoming effective and update the "effective date" at the top of this Privacy Policy.

You are advised to review this Privacy Policy periodically for any changes. Changes to this Privacy Policy are effective when they are posted on this page.

Contact Us

If you have any questions about this Privacy Policy, please contact us:




隱私政策範例

https://medium.com/%E5%BD%BC%E5%BE%97%E6%BD%98%E7%9A%84-swift-ios-app-%E9%96%8B%E7%99%BC%E5%95%8F%E9%A1%8C%E8%A7%A3%E7%AD%94%E9%9B%86/7bc4746cf75d

https://www.privacypolicies.com/privacy/view/c363f2a10a7cd0d95f603eee66224222

內容存檔如下:

Privacy Policy

Effective date: October 02, 2018

小兔英文單字 ("us", "we", or "our") operates the 小兔英文單字 mobile application (hereinafter referred to as the "Service").

This page informs you of our policies regarding the collection, use and disclosure of personal data when you use our Service and the choices you have associated with that data. This Privacy Policy is managed by Privacy Policy Generator.

We use your data to provide and improve the Service. By using the Service, you agree to the collection and use of information in accordance with this policy. Unless otherwise defined in this Privacy Policy, the terms used in this Privacy Policy have the same meanings as in our Terms and Conditions.

Definitions

  • Service

    Service is the 小兔英文單字 mobile application operated by 小兔英文單字

  • Personal Data

    Personal Data means data about a living individual who can be identified from those data (or from those and other information either in our possession or likely to come into our possession).

  • Usage Data

    Usage Data is data collected automatically either generated by the use of the Service or from the Service infrastructure itself (for example, the duration of a page visit).

  • Cookies

    Cookies are small files stored on your device (computer or mobile device).

Information Collection and Use

We collect several different types of information for various purposes to provide and improve our Service to you.

Types of Data Collected

Personal Data

While using our Service, we may ask you to provide us with certain personally identifiable information that can be used to contact or identify you ("Personal Data"). Personally identifiable information may include, but is not limited to:

  • Cookies and Usage Data

Usage Data

When you access the Service with a mobile device, we may collect certain information automatically, including, but not limited to, the type of mobile device you use, your mobile device unique ID, the IP address of your mobile device, your mobile operating system, the type of mobile Internet browser you use, unique device identifiers and other diagnostic data ("Usage Data").

Tracking & Cookies Data

We use cookies and similar tracking technologies to track the activity on our Service and we hold certain information. Cookies are files with a small amount of data which may include an anonymous unique identifier. Cookies are sent to your browser from a website and stored on your device. Other tracking technologies are also used such as beacons, tags and scripts to collect and track information and to improve and analyse our Service. You can instruct your browser to refuse all cookies or to indicate when a cookie is being sent. However, if you do not accept cookies, you may not be able to use some portions of our Service. Examples of Cookies we use:

  • Session Cookies. We use Session Cookies to operate our Service.
  • Preference Cookies. We use Preference Cookies to remember your preferences and various settings.
  • Security Cookies. We use Security Cookies for security purposes.

Use of Data

小兔英文單字 uses the collected data for various purposes:

  • To provide and maintain our Service
  • To notify you about changes to our Service
  • To allow you to participate in interactive features of our Service when you choose to do so
  • To provide customer support
  • To gather analysis or valuable information so that we can improve our Service
  • To monitor the usage of our Service
  • To detect, prevent and address technical issues

Transfer of Data

Your information, including Personal Data, may be transferred to - and maintained on - computers located outside of your state, province, country or other governmental jurisdiction where the data protection laws may differ from those of your jurisdiction.

If you are located outside and choose to provide information to us, please note that we transfer the data, including Personal Data, to and process it there.

Your consent to this Privacy Policy followed by your submission of such information represents your agreement to that transfer.

小兔英文單字 will take all the steps reasonably necessary to ensure that your data is treated securely and in accordance with this Privacy Policy and no transfer of your Personal Data will take place to an organisation or a country unless there are adequate controls in place including the security of your data and other personal information.

Disclosure of Data

Legal Requirements

小兔英文單字 may disclose your Personal Data in the good faith belief that such action is necessary to:

  • To comply with a legal obligation
  • To protect and defend the rights or property of 小兔英文單字
  • To prevent or investigate possible wrongdoing in connection with the Service
  • To protect the personal safety of users of the Service or the public
  • To protect against legal liability

Security of Data

The security of your data is important to us but remember that no method of transmission over the Internet or method of electronic storage is 100% secure. While we strive to use commercially acceptable means to protect your Personal Data, we cannot guarantee its absolute security.

Service Providers

We may employ third party companies and individuals to facilitate our Service ("Service Providers"), provide the Service on our behalf, perform Service-related services or assist us in analysing how our Service is used. These third parties have access to your Personal Data only to perform these tasks on our behalf and are obligated not to disclose or use it for any other purpose.

Analytics

We may use third-party Service Providers to monitor and analyse the use of our Service.

Links to Other Sites

Our Service may contain links to other sites that are not operated by us. If you click a third party link, you will be directed to that third party's site. We strongly advise you to review the Privacy Policy of every site you visit. We have no control over and assume no responsibility for the content, privacy policies or practices of any third party sites or services.

Children's Privacy

Our Service does not address anyone under the age of 18 ("Children").

We do not knowingly collect personally identifiable information from anyone under the age of 18. If you are a parent or guardian and you are aware that your Child has provided us with Personal Data, please contact us. If we become aware that we have collected Personal Data from children without verification of parental consent, we take steps to remove that information from our servers.

Changes to This Privacy Policy

We may update our Privacy Policy from time to time. We will notify you of any changes by posting the new Privacy Policy on this page. We will let you know via email and/or a prominent notice on our Service, prior to the change becoming effective and update the "effective date" at the top of this Privacy Policy.

You are advised to review this Privacy Policy periodically for any changes. Changes to this Privacy Policy are effective when they are posted on this page.

Contact Us

If you have any questions about this Privacy Policy, please contact us:



以南非為例,談談落後指標、先行指標等

https://www.storm.mg/investreview2020/article/2907252

我們先用落後指標來檢視 , 南非的狀況

落後指標:失業率 

為什麼一開場先用落後指標,無非是告訴大家,這指標落後於基本面,是一個很好的檢視方式!

如果過去政府有對經濟做出貢獻與努力,最終失業率就會下降

但是很遺憾的,這個南非政府似乎無能改善!

下圖為失業率:數據是29%,截至 2020 年的資料,是近十年最高了


落後的指標看過去是否能夠改善,先行的指標看未來是否有機會改善

先行指標:製造業PMI 

目前的數據是45.7,這是全球前幾名的低!

PMI 低於50就是進入衰退的前兆,45.7這個數字也預告南非未來也不太樂觀!


南非製造業PMI 低於50。

什麼樣的環境造成南非這麼慘呢?

看一個國家就至少也要看他的基礎建設是否完善,

南非的罩門在哪?在於電力不足?因此百業蕭條。


如果一個國家缺電,您想能投資什麼產業?

半導體?不可能。生產線一停電要損失多少?

製造業?產品做一半停電怎麼辦?


所以最後南非可以依賴的就是礦業,一直都是礦業。


也因為南非電力不穩定,甚至導致國家信評可能被降低到更低的垃圾等級,簡稱垃圾中的垃圾 ......


再看看影響南非幣的主要外部因素:美元

美元強,南非幣弱;反之...


南非幣的經常帳:自從2008年以來沒有正數

因此國家缺錢怎麼辦?只好借外債了。以債養債這個國家很慘!

債務占國家 GDP 比重也隨著外債的增加持續高漲!





結論:

1. 南非從基本面來看,離好轉還有很長遠的距離。

2. 如果基本面要轉好,至少南非的電力問題要搞定,而南非電力如果政府不救,就是快要破產的公司了,一個國家搞成這樣不容易!

3. 南非幣可以投資嗎?如果您很喜歡投機的話可以考慮(但是光換匯成本就超過 3%)

4. 南非的展望:南非是新興市場中前五名脆弱的,只要美元轉強,那麼南非可能就是受害最嚴重的國家之一。








開發 iOS,PCH 檔案的配置及使用

https://www.itread01.com/p/398294.html

在 Xcode 6 之前,建立一個新工程時 Xcode 會在 Supporting files 資料夾下面自動建立一個「工程名-Prefix.pch」檔案,這也是一個頭檔案,pch 標頭檔案的內容能被專案中的其他所有原始檔共享和訪問。是一個預編譯檔案。

PCH 檔案的作用

1. 用來包含一些使用頻率較高的標頭檔案

2. 存放一些全域性的巨集

3. 因為是預編譯檔案,會增加編譯時間,所以在 Xcode 6 以後,蘋果為了避免濫用 pch 檔案,不再自動生成。


在 PCH 中定義的巨集會自動新增到所有的檔案中,所以新增的時候要特別注意,一定要區分 C 檔案和 OC 檔案,如果不區分,把 OC 巨集用的內碼表新增到 C 檔案中,C 檔案無法識別 OC 中的框架就會報錯。

詳見課程影片:

https://www.youtube.com/watch?v=PI3hbyaYT2s&list=PLzKtnppOmiXAlARyp-aRjP0e-RsWiS4UW&index=12

還有如何區分 Debug 和 Release 等細節




iOS 開發常用巨集

https://codertw.com/ios/327901/

Objective-C


//字串是否為空
#define kStringIsEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || [str length] < 1 ? YES : NO )
//陣列是否為空
#define kArrayIsEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0)
//字典是否為空
#define kDictIsEmpty(dic) (dic == nil || [dic isKindOfClass:[NSNull class]] || dic.allKeys == 0)
//是否是空物件
#define kObjectIsEmpty(_object) (_object == nil \
|| [_object isKindOfClass:[NSNull class]] \
|| ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) \
|| ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))
//獲取螢幕寬度與高度
#define kScreenWidth \
([[UIScreen mainScreen] respondsToSelector:@selector(nativeBounds)] ? [UIScreen mainScreen].nativeBounds.size.width/[UIScreen mainScreen].nativeScale : [UIScreen mainScreen].bounds.size.width)
#define kScreenHeight \
([[UIScreen mainScreen] respondsToSelector:@selector(nativeBounds)] ? [UIScreen mainScreen].nativeBounds.size.height/[UIScreen mainScreen].nativeScale : [UIScreen mainScreen].bounds.size.height)
#define kScreenSize \
([[UIScreen mainScreen] respondsToSelector:@selector(nativeBounds)] ? CGSizeMake([UIScreen mainScreen].nativeBounds.size.width/[UIScreen mainScreen].nativeScale,[UIScreen mainScreen].nativeBounds.size.height/[UIScreen mainScreen].nativeScale) : [UIScreen mainScreen].bounds.size)
//一些縮寫
#define kApplication  [UIApplication sharedApplication]
#define kKeyWindow   [UIApplication sharedApplication].keyWindow
#define kAppDelegate  [UIApplication sharedApplication].delegate
#define kUserDefaults  [NSUserDefaults standardUserDefaults]
#define kNotificationCenter [NSNotificationCenter defaultCenter]
//APP版本號
#define kAppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
//系統版本號
#define kSystemVersion [[UIDevice currentDevice] systemVersion]
//獲取當前語言
#define kCurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
//判斷是否為iPhone
#define kISiPhone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
//判斷是否為iPad
#define kISiPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
//獲取沙盒Document路徑
#define kDocumentPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
//獲取沙盒temp路徑
#define kTempPath NSTemporaryDirectory()
//獲取沙盒Cache路徑
#define kCachePath [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]
//判斷是真機還是模擬器
#if TARGET_OS_IPHONE
//真機
#endif
#if TARGET_IPHONE_SIMULATOR
//模擬器
#endif
//開發的時候列印,但是釋出的時候不列印的NSLog
#ifdef DEBUG
#define NSLog(...) NSLog(@"%s 第%d行 \n %@\n\n",__func__,__LINE__,[NSString stringWithFormat:__VA_ARGS__])
#else
#define NSLog(...)
#endif
//顏色
#define kRGBColor(r, g, b)  [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
#define kRGBAColor(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(r)/255.0 blue:(r)/255.0 alpha:a]
#define kRandomColor KRGBColor(arc4random_uniform(256)/255.0,arc4random_uniform(256)/255.0,arc4random_uniform(256)/255.0)
#define kColorWithHex(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 kWeakSelf(type) __weak typeof(type) weak##type = type;
#define kStrongSelf(type) __strong typeof(type) type = weak##type;
//由角度轉換弧度
#define kDegreesToRadian(x)  (M_PI * (x) / 180.0)
//由弧度轉換角度
#define kRadianToDegrees(radian) (radian * 180.0) / (M_PI)
//獲取一段時間間隔
#define kStartTime CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();
#define kEndTime NSLog(@"Time: %f", CFAbsoluteTimeGetCurrent() - start)

1.定義尺寸類的巨集


DimensMacros.h
//狀態列高度
#define STATUS_BAR_HEIGHT 20
//NavBar高度
#define NAVIGATION_BAR_HEIGHT 44
//狀態列 + 導航欄 高度
#define STATUS_AND_NAVIGATION_HEIGHT ((STATUS_BAR_HEIGHT)   (NAVIGATION_BAR_HEIGHT))
//螢幕 rect
#define SCREEN_RECT ([UIScreen mainScreen].bounds)
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
#define CONTENT_HEIGHT (SCREEN_HEIGHT - NAVIGATION_BAR_HEIGHT - STATUS_BAR_HEIGHT)
//螢幕解析度
#define SCREEN_RESOLUTION (SCREEN_WIDTH * SCREEN_HEIGHT * ([UIScreen mainScreen].scale))
//廣告欄高度
#define BANNER_HEIGHT 215
#define STYLEPAGE_HEIGHT 21
#define SMALLTV_HEIGHT 77
#define SMALLTV_WIDTH 110
#define FOLLOW_HEIGHT 220
#define SUBCHANNEL_HEIGHT 62

2.定義沙盒目錄檔案的巨集


PathMacros.h
//檔案目錄
#define kPathTemp          NSTemporaryDirectory()
#define kPathDocument        [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
#define kPathCache         [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0]
#define kPathSearch         [kPathDocument stringByAppendingPathComponent:@"Search.plist"]
#define kPathMagazine        [kPathDocument stringByAppendingPathComponent:@"Magazine"]
#define kPathDownloadedMgzs     [kPathMagazine stringByAppendingPathComponent:@"DownloadedMgz.plist"]
#define kPathDownloadURLs      [kPathMagazine stringByAppendingPathComponent:@"DownloadURLs.plist"]
#define kPathOperation       [kPathMagazine stringByAppendingPathComponent:@"Operation.plist"]
#define kPathSplashScreen      [kPathCache stringByAppendingPathComponent:@"splashScreen"]
#endif

3.工具類的巨集


UtilsMacros.h
//Log utils marco
#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define DLog(...)
#endif
#ifdef DEBUG
#define ULog(...)
//#define ULog(fmt, ...) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%s\n [Line %d] ", __PRETTY_FUNCTION__, __LINE__] message:[NSString stringWithFormat:fmt, ##__VA_ARGS__] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show]; }
#else
#define ULog(...)
#endif
//System version utils
#define SYSTEM_VERSION_EQUAL_TO(v)         ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)       ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)         ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)   ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
// 獲取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 IsPortrait ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown)
#define IsNilOrNull(_ref)  (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]))
//角度轉弧度
#define DEGREES_TO_RADIANS(d) (d * M_PI / 180)
//大於等於7.0的ios版本
#define iOS7_OR_LATER SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")
//大於等於8.0的ios版本
#define iOS8_OR_LATER SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")
//iOS6時,導航VC中view的起始高度
#define YH_HEIGHT (iOS7_OR_LATER ? 64:0)
//獲取系統時間戳
#define getCurentTime [NSString stringWithFormat:@"%ld", (long)[[NSDate date] timeIntervalSince1970]]

4.通知Notification相關的巨集


NotificationMacros.h
//系統Notification定義
#define TNCancelFavoriteProductNotification   @"TNCancelFavoriteProductNotification"   //取消收藏時
#define TNMarkFavoriteProductNotification    @"TNMarkFavoriteProductNotification"    //標記收藏時
#define kNotficationDownloadProgressChanged   @"kNotficationDownloadProgressChanged"   //下載進度變化
#define kNotificationPauseDownload       @"kNotificationPauseDownload"        //暫停下載
#define kNotificationStartDownload       @"kNotificationStartDownload"        //開始下載
#define kNotificationDownloadSuccess      @"kNotificationDownloadSuccess"       //下載成功
#define kNotificationDownloadFailed       @"kNotificationDownloadFailed"       //下載失敗
#define kNotificationDownloadNewMagazine    @"kNotificationDownloadNewMagazine"
服務端API介面的巨集
APIStringMacros.h
//////////////////////////////////////////////////////////////////////////////////////////////////
//介面名稱相關
#ifdef DEBUG
//Debug狀態下的測試API
#define API_BASE_URL_STRING   @"http://boys.test.companydomain.com/api/"
#else
//Release狀態下的線上API
#define API_BASE_URL_STRING   @"http://www.companydomain.com/api/"
#endif
//介面
#define GET_CONTENT_DETAIL   @"channel/getContentDetail" //獲取內容詳情(含上一個和下一個)
#define GET_COMMENT_LIST    @"comment/getCommentList"  //獲取評論列表
#define COMMENT_LOGIN      @"comment/login"      //獲取評論列表
#define COMMENT_PUBLISH     @"comment/publish"     //釋出評論
#define COMMENT_DELETE     @"comment/delComment"    //刪除評論
#define LOGINOUT        @"common/logout"      //登出
還有很多其他型別的巨集,此處不一一列舉
建立一個import所有巨集相關的檔案Macros.h
Macros.h
#import "UtilsMacros.h"
#import "APIStringMacros.h"
#import "DimensMacros.h"
#import "NotificationMacros.h"
#import "SharePlatformMacros.h"
#import "StringMacros.h"
#import "UserBehaviorMacros.h"
#import "PathMacros.h"
在xcode專案的pch檔案中,匯入Macros.h檔案
XcodeProjectName-Prefix.pch
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "Macros.h"
#endif



程式語言編年史

程式語言編年史原文 下面這張圖片描繪了整個程式語言的歷史。包括各種程式語言的發明人、程式語言的特點和適用領域、被什麼網站或公司使用等 (檢視 完整高清圖 )。 之所以會有那麼多不同的程式語言是因為設計程式語言的初衷不同、對語言學習曲線的追求不同、不同程式之間的執行成本差異...