Created
January 20, 2016 07:24
-
-
Save liruqi/06810931d0b7c8cd02b6 to your computer and use it in GitHub Desktop.
Put to adjacent view in the horizontal middle of screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// No working anyway | |
CGSize screenSz = [UIScreen mainScreen].bounds.size; | |
CGSize leftSz = [self.haveAccountLabel intrinsicContentSize]; | |
CGSize rightSz = [self.signInButton intrinsicContentSize]; | |
CGFloat contentWidth = leftSz.width + rightSz.width + 8; | |
CGFloat x = (screenSz.width - contentWidth) / 2; | |
if (x < 0) { | |
NSLog(@"Text overflow %lf > %lf", contentWidth, screenSz.width); | |
} else { | |
_haveAccountLabel.translatesAutoresizingMaskIntoConstraints = YES; | |
_signInButton.translatesAutoresizingMaskIntoConstraints = YES; | |
CGRect f = _haveAccountLabel.frame; | |
f.origin.x = 0; | |
f.size.width = x + leftSz.width; | |
self.haveAccountLabel.frame = f; | |
f = self.signInButton.frame; | |
f.origin.x = x + leftSz.width + 8; | |
f.size.width = screenSz.width - f.origin.x; | |
self.signInButton.frame = f; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment