From cc57e890bf0a4e999d354ac9eec7baa28734e3a7 Mon Sep 17 00:00:00 2001 From: Leo Date: Fri, 28 Apr 2017 15:13:01 +0800 Subject: [PATCH] Fix issue #36 --- Demo/LCActionSheetDemo/ViewController.m | 9 ++++++++- Sources/LCActionSheet.m | 14 +++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Demo/LCActionSheetDemo/ViewController.m b/Demo/LCActionSheetDemo/ViewController.m index 18b27e3..b726d4e 100644 --- a/Demo/LCActionSheetDemo/ViewController.m +++ b/Demo/LCActionSheetDemo/ViewController.m @@ -8,6 +8,7 @@ #import "ViewController.h" #import +#import #define KEY_WINDOW [UIApplication sharedApplication].keyWindow @@ -33,12 +34,18 @@ - (void)viewDidLoad { }); textField.placeholder = @"Tap screen to hide keyboard.."; textField.backgroundColor = [UIColor whiteColor]; + textField.layer.cornerRadius = 4.0; textField.layer.shadowColor = [UIColor blackColor].CGColor; textField.layer.shadowRadius = 2; textField.layer.shadowOpacity = 0.3; textField.layer.shadowOffset = CGSizeMake(0, 1.2); - textField.frame = CGRectMake(10.0, 25.0, [UIScreen mainScreen].bounds.size.width - 10.0 * 2, 44.0); [self.view addSubview:textField]; + [textField mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.equalTo(self.view).offset(10.0); + make.right.equalTo(self.view).offset(-10.0); + make.top.equalTo(self.view).offset(30.0); + make.height.offset(44.0); + }]; } - (void)viewWillAppear:(BOOL)animated { diff --git a/Sources/LCActionSheet.m b/Sources/LCActionSheet.m index e7caf2c..d582a60 100644 --- a/Sources/LCActionSheet.m +++ b/Sources/LCActionSheet.m @@ -473,7 +473,7 @@ - (void)appendButtonsWithTitles:(NSArray *)titles atIndexes:(NSIndex [self updateBottomView]; [self updateTableView]; } - + - (void)handleDidChangeStatusBarOrientation { if (self.autoHideWhenDeviceRotated) { [self hideWithButtonIndex:self.cancelButtonIndex]; @@ -729,13 +729,17 @@ - (void)show { UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; window.windowLevel = UIWindowLevelStatusBar; - [window addSubview:self]; - [self mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.equalTo(window); - }]; [window makeKeyAndVisible]; self.window = window; + UIViewController *viewController = [[UIViewController alloc] init]; + window.rootViewController = viewController; + + [viewController.view addSubview:self]; + [self mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.equalTo(viewController.view); + }]; + [self.window layoutIfNeeded]; __weak typeof(self) weakSelf = self;