//
// Layout.h
// HappyStyle
//
// Created by Zhanggaoju on 2018/6/19.
// Copyright © 2018年 ZhangGaoju. All rights reserved.
//
/* 屏幕适配 */
#ifndef Layout_h
#define Layout_h
/** 屏幕高度 */
#define screen_height [UIScreen mainScreen].bounds.size.height
/** 屏幕宽度 */
#define screen_width [UIScreen mainScreen].bounds.size.width
/** 屏幕高度比例 */
#define scale_height (screen_height *1.0/667)
/** 屏幕宽度比例 */
#define scale_width (screen_width *1.0/375)
/** 导航栏高度 */
#define navigationBar_height44
/** 状态栏高度 */
#define statusBar_height iPhoneX ?44:20
/** 导航栏+状态栏高度 */
#define navigationBar_statusBar_height iPhoneX ?88:64
/** tabBar高度 */
#define tabBar_height iPhoneX ?83:49
/** 底部安全区域 */
#define safeArea_bottom iPhoneX ?34:0
/** 分割线高度 */
#define splite_height1.0*scale_height
#define Window [UIApplication sharedApplication].delegate.window
#define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125,2436), [[UIScreen mainScreen] currentMode].size) : NO)
#pragma mark -
#pragma mark masonry
/** edges */
#define makeEdgesConstraint(view) \
if (@available(iOS11.0, *)) { \
if (iPhoneX) { \
make.edges.mas_equalTo(self.view.safeAreaInsets);\
} else { \
make.edges.mas_equalTo(self.view); \
}\
} else { \
make.edges.mas_equalTo(self.view); \
}
/** left */
#define makeLeftConstraint(view) \
if (@available(iOS11.0, *)) {\
if (iPhoneX) { \
make.left.mas_equalTo(self.view.mas_safeAreaLayoutGuideLeft); \
} else { \
make.left.mas_equalTo(self.view); \
}\
} else { \
make.left.mas_equalTo(self.view); \
}
/** right */
#define makeRightConstraint(view) \
if (@available(iOS11.0, *)) { \
if (iPhoneX) { \
make.right.mas_equalTo(self.view.mas_safeAreaLayoutGuideRight); \
} else { \
make.right.mas_equalTo(self.view); \
}\
} else { \
make.right.mas_equalTo(self.view); \
}
/** top */
#define makeTopConstraint(view) \
if (@available(iOS11.0, *)) { \
if (iPhoneX) { \
make.top.mas_equalTo(self.view.mas_safeAreaLayoutGuideTop); \
} else { \
make.top.mas_equalTo(self.view); \
}\
} else { \
make.top.mas_equalTo(self.view); \
}
/** bottom */
#define makeBottomConstraint(view) \
if (@available(iOS11.0, *)) { \
if (iPhoneX) { \
make.bottom.mas_equalTo(self.view.mas_safeAreaLayoutGuideBottom); \
} else { \
make.bottom.mas_equalTo(self.view); \
}\
} else { \
make.bottom.mas_equalTo(self.view); \
}
/** constraint */
#define makeConstraint(constraint, view, viewConstraint, safeAreaLayoutGuide) \
if (@available(iOS11.0, *)) { \
make.constraint.mas_equalTo(view.safeAreaLayoutGuide); \
} else { \
make.constraint.mas_equalTo(view.viewConstraint); \
}
/** constraintOffset */
#define makeConstraintOffset(constraint, view, viewConstraint, safeAreaLayoutGuide, offset) \
if (@available(iOS11.0, *)) { \
make.constraint.mas_equalTo(view.safeAreaLayoutGuide).mas_offset(offset); \
} else { \
make.constraint.mas_equalTo(view.viewConstraint).mas_offset(offset); \
}
#endif /* Layout_h */