iOS 2018新IPhone机型适配
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>NS_ASSUME_NONNULL_BEGIN/** 状态栏高度 */
#define STATUS_BAR_HEIGHT [Helper status_ber_height]
/** 导航栏高度 */
#define NAVIGATION_BAR_HEIGHT [Helper navgation_ber_height]
/** tabBar高度 */
#define TAB_BAR_HEIGHT [Helper tab_ber_height]
/** Home 条 */
#define HOME_INDICATOR_HEIGHT [Helper home_button_height]
/** 内容高度 */
#define Content_HEIGHT(nav,tab) [Helper content_height:nav isTab:tab]typedef NS_ENUM(NSUInteger, iPhoneType) {iPhoneTypeiPhone4s,iPhoneTypeiPhone5s,iPhoneTypeiPhone,iPhoneTypeiPhonePlus,iPhoneTypeiPhoneX_XS,iPhoneTypeiPhoneXS,iPhoneTypeiPhoneXR,iPhoneTypeiPhoneXMax,iPhoneTypeiPad,iPhoneTypeMoNiQi,iPhoneTypeUnkuown
};@interface Helper : NSObject
/**640 × 960 iPhone4s Default@2x640 × 1136 iPhone5s Default-568h@2x750 × 1334 iPhone Default-667h@2x1242 × 2208 iPhonePlus Default-736h@3x1125 × 2436 iPhoneX, XS Default-812h@3x828 x 1792 iPhoneXR Default-828h@2x1242 x 2688 iPhoneX Max Default-1242h@3x*/
+(iPhoneType)iphone;/** 是否柳海屏 */
+(BOOL)liuHaiPing;
/** 状态栏 */
+(CGFloat)status_ber_height;
/** 导航条 */
+(CGFloat)navgation_ber_height;
/** tabbar */
+(CGFloat)tab_ber_height;
/** Home条 */
+(CGFloat)home_button_height;
/** 显示内容区域高度 */
+(CGFloat)content_height:(BOOL)isNav isTab:(BOOL)isTab;@endNS_ASSUME_NONNULL_END
#import "Helper.h"@implementation Helper
/**640 × 960 iPhone4s Default@2x640 × 1136 iPhone5s Default-568h@2x750 × 1334 iPhone Default-667h@2x1242 × 2208 iPhonePlus Default-736h@3x1125 × 2436 iPhoneX, XS Default-812h@3x828 x 1792 iPhoneXR Default-828h@2x1242 x 2688 iPhoneX Max Default-1242h@3x*/
+(iPhoneType)iphone
{BOOL ipad = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad;if (ipad) { return iPhoneTypeiPad; }CGSize size = [[UIScreen mainScreen] currentMode].size;if ( CGSizeEqualToSize(size, CGSizeMake(640, 960))) {return iPhoneTypeiPhone4s;}else if (CGSizeEqualToSize(size, CGSizeMake(640, 1136))){return iPhoneTypeiPhone5s;}else if (CGSizeEqualToSize(size, CGSizeMake(750, 1334))){return iPhoneTypeiPhone;}else if (CGSizeEqualToSize(size, CGSizeMake(1242, 2208))){return iPhoneTypeiPhonePlus;}else if (CGSizeEqualToSize(size, CGSizeMake(1125, 2436))){return iPhoneTypeiPhoneX_XS;}else if (CGSizeEqualToSize(size, CGSizeMake(828, 1792))){return iPhoneTypeiPhoneXR;}else if (CGSizeEqualToSize(size, CGSizeMake(1242, 2688))){return iPhoneTypeiPhoneXMax;}else{return iPhoneTypeUnkuown;};}+(BOOL)liuHaiPing
{iPhoneType type = [self iphone];switch (type) {case iPhoneTypeiPhone4s ... iPhoneTypeiPhonePlus:{return NO;}break;default:return YES;break;}
}+(CGFloat)status_ber_height
{iPhoneType type = [self iphone];switch (type) {case iPhoneTypeiPhone4s ... iPhoneTypeiPhonePlus:{return 20.f;}break;case iPhoneTypeiPhoneX_XS:{return 44.f;}break;case iPhoneTypeiPhoneXR:{return 44.f;}break;case iPhoneTypeiPhoneXMax:{return 44.f;}break;default:return 20.f;break;}
}+(CGFloat)navgation_ber_height
{iPhoneType type = [self iphone];switch (type) {case iPhoneTypeiPhone4s ... iPhoneTypeiPhonePlus:{return 64.f;}break;case iPhoneTypeiPhoneX_XS:{return 88.f;}break;case iPhoneTypeiPhoneXR:{return 88.f;}break;case iPhoneTypeiPhoneXMax:{return 88.f;}break;default:return 64.f;break;}
}+(CGFloat)tab_ber_height
{iPhoneType type = [self iphone];switch (type) {case iPhoneTypeiPhone4s ... iPhoneTypeiPhonePlus:{return 49.f;}break;case iPhoneTypeiPhoneX_XS:{return 49.f+34.f;}break;case iPhoneTypeiPhoneXR:{return 49.f+34.f;}break;case iPhoneTypeiPhoneXMax:{return 49.f+34.f;}break;default:return 49.f+34.f;break;}}+(CGFloat)home_button_height
{iPhoneType type = [self iphone];switch (type) {case iPhoneTypeiPhone4s ... iPhoneTypeiPhonePlus:{return 0;}break;case iPhoneTypeiPhoneX_XS:{return 34.f;}break;case iPhoneTypeiPhoneXR:{return 34.f;}break;case iPhoneTypeiPhoneXMax:{return 34.f;}break;default:return 34.f;break;}
}+(CGFloat)content_height:(BOOL)isNav isTab:(BOOL)isTab
{CGFloat h = [UIScreen mainScreen].bounds.size.height;if (isNav == YES){h -= [self navgation_ber_height];}if (isTab == YES){h -= [self tab_ber_height];}return h;
}
@end
iOS 2018新IPhone机型适配
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>NS_ASSUME_NONNULL_BEGIN/** 状态栏高度 */
#define STATUS_BAR_HEIGHT [Helper status_ber_height]
/** 导航栏高度 */
#define NAVIGATION_BAR_HEIGHT [Helper navgation_ber_height]
/** tabBar高度 */
#define TAB_BAR_HEIGHT [Helper tab_ber_height]
/** Home 条 */
#define HOME_INDICATOR_HEIGHT [Helper home_button_height]
/** 内容高度 */
#define Content_HEIGHT(nav,tab) [Helper content_height:nav isTab:tab]typedef NS_ENUM(NSUInteger, iPhoneType) {iPhoneTypeiPhone4s,iPhoneTypeiPhone5s,iPhoneTypeiPhone,iPhoneTypeiPhonePlus,iPhoneTypeiPhoneX_XS,iPhoneTypeiPhoneXS,iPhoneTypeiPhoneXR,iPhoneTypeiPhoneXMax,iPhoneTypeiPad,iPhoneTypeMoNiQi,iPhoneTypeUnkuown
};@interface Helper : NSObject
/**640 × 960 iPhone4s Default@2x640 × 1136 iPhone5s Default-568h@2x750 × 1334 iPhone Default-667h@2x1242 × 2208 iPhonePlus Default-736h@3x1125 × 2436 iPhoneX, XS Default-812h@3x828 x 1792 iPhoneXR Default-828h@2x1242 x 2688 iPhoneX Max Default-1242h@3x*/
+(iPhoneType)iphone;/** 是否柳海屏 */
+(BOOL)liuHaiPing;
/** 状态栏 */
+(CGFloat)status_ber_height;
/** 导航条 */
+(CGFloat)navgation_ber_height;
/** tabbar */
+(CGFloat)tab_ber_height;
/** Home条 */
+(CGFloat)home_button_height;
/** 显示内容区域高度 */
+(CGFloat)content_height:(BOOL)isNav isTab:(BOOL)isTab;@endNS_ASSUME_NONNULL_END
#import "Helper.h"@implementation Helper
/**640 × 960 iPhone4s Default@2x640 × 1136 iPhone5s Default-568h@2x750 × 1334 iPhone Default-667h@2x1242 × 2208 iPhonePlus Default-736h@3x1125 × 2436 iPhoneX, XS Default-812h@3x828 x 1792 iPhoneXR Default-828h@2x1242 x 2688 iPhoneX Max Default-1242h@3x*/
+(iPhoneType)iphone
{BOOL ipad = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad;if (ipad) { return iPhoneTypeiPad; }CGSize size = [[UIScreen mainScreen] currentMode].size;if ( CGSizeEqualToSize(size, CGSizeMake(640, 960))) {return iPhoneTypeiPhone4s;}else if (CGSizeEqualToSize(size, CGSizeMake(640, 1136))){return iPhoneTypeiPhone5s;}else if (CGSizeEqualToSize(size, CGSizeMake(750, 1334))){return iPhoneTypeiPhone;}else if (CGSizeEqualToSize(size, CGSizeMake(1242, 2208))){return iPhoneTypeiPhonePlus;}else if (CGSizeEqualToSize(size, CGSizeMake(1125, 2436))){return iPhoneTypeiPhoneX_XS;}else if (CGSizeEqualToSize(size, CGSizeMake(828, 1792))){return iPhoneTypeiPhoneXR;}else if (CGSizeEqualToSize(size, CGSizeMake(1242, 2688))){return iPhoneTypeiPhoneXMax;}else{return iPhoneTypeUnkuown;};}+(BOOL)liuHaiPing
{iPhoneType type = [self iphone];switch (type) {case iPhoneTypeiPhone4s ... iPhoneTypeiPhonePlus:{return NO;}break;default:return YES;break;}
}+(CGFloat)status_ber_height
{iPhoneType type = [self iphone];switch (type) {case iPhoneTypeiPhone4s ... iPhoneTypeiPhonePlus:{return 20.f;}break;case iPhoneTypeiPhoneX_XS:{return 44.f;}break;case iPhoneTypeiPhoneXR:{return 44.f;}break;case iPhoneTypeiPhoneXMax:{return 44.f;}break;default:return 20.f;break;}
}+(CGFloat)navgation_ber_height
{iPhoneType type = [self iphone];switch (type) {case iPhoneTypeiPhone4s ... iPhoneTypeiPhonePlus:{return 64.f;}break;case iPhoneTypeiPhoneX_XS:{return 88.f;}break;case iPhoneTypeiPhoneXR:{return 88.f;}break;case iPhoneTypeiPhoneXMax:{return 88.f;}break;default:return 64.f;break;}
}+(CGFloat)tab_ber_height
{iPhoneType type = [self iphone];switch (type) {case iPhoneTypeiPhone4s ... iPhoneTypeiPhonePlus:{return 49.f;}break;case iPhoneTypeiPhoneX_XS:{return 49.f+34.f;}break;case iPhoneTypeiPhoneXR:{return 49.f+34.f;}break;case iPhoneTypeiPhoneXMax:{return 49.f+34.f;}break;default:return 49.f+34.f;break;}}+(CGFloat)home_button_height
{iPhoneType type = [self iphone];switch (type) {case iPhoneTypeiPhone4s ... iPhoneTypeiPhonePlus:{return 0;}break;case iPhoneTypeiPhoneX_XS:{return 34.f;}break;case iPhoneTypeiPhoneXR:{return 34.f;}break;case iPhoneTypeiPhoneXMax:{return 34.f;}break;default:return 34.f;break;}
}+(CGFloat)content_height:(BOOL)isNav isTab:(BOOL)isTab
{CGFloat h = [UIScreen mainScreen].bounds.size.height;if (isNav == YES){h -= [self navgation_ber_height];}if (isTab == YES){h -= [self tab_ber_height];}return h;
}
@end
发布评论