From 85899c662bad48fb4d23f38eb10d088ae86bd228 Mon Sep 17 00:00:00 2001 From: chanjh Date: Mon, 18 Sep 2017 17:29:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=20SheetView=20=E9=80=82=E9=85=8D=20iP?= =?UTF-8?q?hone=20X?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 SheetView 距离底部增加, 以避免挡住底部 Home 区域 --- Classes/MMSheetView.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Classes/MMSheetView.m b/Classes/MMSheetView.m index f016653..0d7a462 100644 --- a/Classes/MMSheetView.m +++ b/Classes/MMSheetView.m @@ -121,21 +121,29 @@ - (instancetype)initWithTitle:(NSString *)title items:(NSArray *)items self.cancelButton = [UIButton mm_buttonWithTarget:self action:@selector(actionCancel)]; [self addSubview:self.cancelButton]; + [self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self.buttonView); make.height.mas_equalTo(config.buttonHeight); make.top.equalTo(self.buttonView.mas_bottom).offset(8); }]; + self.cancelButton.titleLabel.font = [UIFont systemFontOfSize:config.buttonFontSize]; [self.cancelButton setBackgroundImage:[UIImage mm_imageWithColor:config.backgroundColor] forState:UIControlStateNormal]; [self.cancelButton setBackgroundImage:[UIImage mm_imageWithColor:config.itemPressedColor] forState:UIControlStateHighlighted]; [self.cancelButton setTitle:config.defaultTextCancel forState:UIControlStateNormal]; [self.cancelButton setTitleColor:config.itemNormalColor forState:UIControlStateNormal]; - + CGFloat btmOffset = 0; + CGSize screenSize = [UIScreen mainScreen].bounds.size; + if (screenSize.height == 812){ + btmOffset = 43; // iPhoneX Portrait + } + if ( screenSize.width == 812 ) { + btmOffset = 33; // iPhoneX Landscape + } [self mas_updateConstraints:^(MASConstraintMaker *make) { - make.bottom.equalTo(self.cancelButton.mas_bottom); + make.bottom.equalTo(self.cancelButton.mas_bottom).offset(btmOffset); }]; - } return self;