From 8b3c31c1d4ed90e35db42cce4b2437a476aea510 Mon Sep 17 00:00:00 2001 From: dengfeng520 Date: Thu, 26 Sep 2019 22:51:08 +0800 Subject: [PATCH] =?UTF-8?q?iOS=20=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VPImageCropperViewController.m | 22 +++++++++++++-- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++ .../Base.lproj/Main.storyboard | 27 ++++++++++--------- 3 files changed, 43 insertions(+), 14 deletions(-) create mode 100644 VPImageCropperDemo/VPImageCropperDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/VPImageCropperDemo/VPImageCropper/VPImageCropperViewController.m b/VPImageCropperDemo/VPImageCropper/VPImageCropperViewController.m index 501af3e..8f60667 100644 --- a/VPImageCropperDemo/VPImageCropper/VPImageCropperViewController.m +++ b/VPImageCropperDemo/VPImageCropper/VPImageCropperViewController.m @@ -100,7 +100,7 @@ - (void)initView { } - (void)initControlBtn { - UIButton *cancelBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 50.0f, 100, 50)]; + UIButton *cancelBtn = [[UIButton alloc] init]; cancelBtn.backgroundColor = [UIColor blackColor]; cancelBtn.titleLabel.textColor = [UIColor whiteColor]; [cancelBtn setTitle:@"Cancel" forState:UIControlStateNormal]; @@ -111,8 +111,17 @@ - (void)initControlBtn { [cancelBtn setTitleEdgeInsets:UIEdgeInsetsMake(5.0f, 5.0f, 5.0f, 5.0f)]; [cancelBtn addTarget:self action:@selector(cancel:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:cancelBtn]; + cancelBtn.translatesAutoresizingMaskIntoConstraints = false; + [[cancelBtn.leftAnchor constraintEqualToAnchor:self.view.leftAnchor constant:0] setActive:true]; + if (@available(iOS 11.0, *)) { + [[cancelBtn.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor constant:0] setActive:true]; + } else { + [[cancelBtn.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor constant:0] setActive:true]; + } + [[cancelBtn.widthAnchor constraintEqualToConstant:100] setActive:true]; + [[cancelBtn.heightAnchor constraintEqualToConstant:50] setActive:true]; - UIButton *confirmBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width - 100.0f, self.view.frame.size.height - 50.0f, 100, 50)]; + UIButton *confirmBtn = [[UIButton alloc] init]; confirmBtn.backgroundColor = [UIColor blackColor]; confirmBtn.titleLabel.textColor = [UIColor whiteColor]; [confirmBtn setTitle:@"OK" forState:UIControlStateNormal]; @@ -124,6 +133,15 @@ - (void)initControlBtn { [confirmBtn setTitleEdgeInsets:UIEdgeInsetsMake(5.0f, 5.0f, 5.0f, 5.0f)]; [confirmBtn addTarget:self action:@selector(confirm:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:confirmBtn]; + confirmBtn.translatesAutoresizingMaskIntoConstraints = false; + [[confirmBtn.rightAnchor constraintEqualToAnchor:self.view.rightAnchor constant:0] setActive:true]; + if (@available(iOS 11.0, *)) { + [[confirmBtn.bottomAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.bottomAnchor constant:0] setActive:true]; + } else { + [[confirmBtn.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor constant:0] setActive:true]; + } + [[confirmBtn.widthAnchor constraintEqualToConstant:100] setActive:true]; + [[confirmBtn.heightAnchor constraintEqualToConstant:50] setActive:true]; } - (void)cancel:(id)sender { diff --git a/VPImageCropperDemo/VPImageCropperDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/VPImageCropperDemo/VPImageCropperDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/VPImageCropperDemo/VPImageCropperDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/VPImageCropperDemo/VPImageCropperDemo/Base.lproj/Main.storyboard b/VPImageCropperDemo/VPImageCropperDemo/Base.lproj/Main.storyboard index 40950c6..4db7e13 100644 --- a/VPImageCropperDemo/VPImageCropperDemo/Base.lproj/Main.storyboard +++ b/VPImageCropperDemo/VPImageCropperDemo/Base.lproj/Main.storyboard @@ -1,26 +1,29 @@ - - + + + - + + + - + + + + + - + - + + - - - - - - \ No newline at end of file +