-
1、判斷是不是iOS11
ocif (@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é)
