開發(fā)中總結(jié)

  • 1、判斷是不是iOS11
    oc

    if (@available(iOS 11.0, *)) {
          _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
          
          _tableView.estimatedRowHeight = 0;
          _tableView.estimatedSectionHeaderHeight = 0;
          _tableView.estimatedSectionFooterHeight = 0;
      }
    

swift

if #available(iOS 11.0, *) {
        self.tableView.contentInsetAdjustmentBehavior = .never
    } else {
        self.automaticallyAdjustsScrollViewInsets = false
    }
  • 2、iOS 學(xué)習(xí)必備的開源項目及庫
    *3 聲明屬性編譯器默認(rèn)會給我們生成對應(yīng)的私有成員變量,其實屬性就是私有成員變量+getter+setter罷了;
    這里我們不考慮幺蛾子情況,比如聲明了兩個屬性year和month,你又寫了這樣的代碼@synthesize year =
    month;那么不好意思,這樣的話編譯器不會生成_month和_year成員變量了,也不會生成month的getter和setter方法,只會生成一個month成員變量和year的getter和setter方法,操作self.year
    就相當(dāng)于操作了month成員變量;
    4、別再用 CD 切換目錄了

    5、iOS小技巧總結(jié),絕對有你想要的
    6、判斷iPhone的尺寸
    JcCJp.png
#define IS_IPHONE        (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_4      (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 480.0)
#define IS_IPHONE_5      (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0)
#define IS_IPHONE_6      (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0)
#define IS_IPHONE_6PLUS  (IS_IPHONE && [[UIScreen mainScreen] nativeScale] == 3.0f)
#define IS_IPHONE_6_PLUS (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 736.0)
#define IS_IPHONE_X      (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 812.0)
#define IS_IPHONE_XS      (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 812.0)
#define IS_IPHONE_X_MAX      (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 896.0)
#define IS_RETINA        ([[UIScreen mainScreen] scale] >= 2.0) // 3.0 for iPhone X, 2.0 for others
#define IS_IPAD_DEVICE   [(NSString*)[UIDevice currentDevice].model hasPrefix:@"iPad"]

iPhoneXs iPhoneXs Max iPhoneXr 界面適配
iPhoneXS、XS Max與iPhoneXR 適配
Xcode10 暨iPhoneXS,iPhoneXS Max,iPhoneXR適配小結(jié)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容