Created
November 1, 2015 09:50
-
-
Save D-32/217d89cf87c2a6615392 to your computer and use it in GitHub Desktop.
Correctly vertically center a text field
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
CGFloat topLetterPadding = self.nameLabel.font.ascender - self.nameLabel.font.capHeight; | |
NSLayoutConstraint *nameLabelCenterConstraint = [NSLayoutConstraint constraintWithItem:self.nameLabel | |
attribute:NSLayoutAttributeCenterY | |
relatedBy:NSLayoutRelationEqual | |
toItem:self | |
attribute:NSLayoutAttributeCenterY | |
multiplier:1 | |
constant:roundf(-(topLetterPadding / 2))]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment