From 6c179caa99b76acb2ef0571343da4f8070c60f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Lupian=CC=83ez=20Casares?= Date: Mon, 23 Apr 2018 17:09:39 +0300 Subject: [PATCH] Adds autolayout rules to adapt the UIView more accurately --- .../NativeEditPlugin/Plugins/iOS/EditBox_iOS.m | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/release/NativeEditPlugin/Plugins/iOS/EditBox_iOS.m b/release/NativeEditPlugin/Plugins/iOS/EditBox_iOS.m index fca9384..87b5ef0 100755 --- a/release/NativeEditPlugin/Plugins/iOS/EditBox_iOS.m +++ b/release/NativeEditPlugin/Plugins/iOS/EditBox_iOS.m @@ -53,9 +53,22 @@ +(void) initializeEditBox:(UIViewController*) _unityViewController unityName:(c dictEditBox = [[NSMutableDictionary alloc] init]; CGRect frameView = unityViewController.view.frame; - frameView.origin = CGPointMake(0.0f, 0.0f); viewPlugin = [[EditBoxHoldView alloc] initHoldView:frameView]; - [unityViewController.view addSubview:viewPlugin]; + [viewPlugin setTranslatesAutoresizingMaskIntoConstraints:NO]; + [[unityViewController view] addSubview:viewPlugin]; + + NSArray *attributes = @[@(NSLayoutAttributeLeft), @(NSLayoutAttributeTop), @(NSLayoutAttributeRight), @(NSLayoutAttributeBottom)]; + NSMutableArray *constraints = [NSMutableArray array]; + [attributes enumerateObjectsUsingBlock:^(id _Nonnull attribute, NSUInteger idx, BOOL * _Nonnull stop) { + [constraints addObject:[NSLayoutConstraint constraintWithItem:viewPlugin + attribute:[attribute integerValue] + relatedBy:NSLayoutRelationEqual + toItem:[viewPlugin superview] + attribute:[attribute integerValue] + multiplier:1.0f + constant:0.0f]]; + }]; + [NSLayoutConstraint activateConstraints:constraints]; strcpy(g_unityName, unityName); }