GBFlatButton
GBFlatButton copied to clipboard
Button disappears if I use a horizontal centering layout constraint
Button renders fine if I set leading and trailing layout constraints, but anytime I try to use a width layout constraint with a horizontal centering constraint (either to its superview or relative to another element) the button fails to render at all? Any ideas?
The button still functions ... it just isn't visible at all.
Change the class to a UIButton with no other changes and it renders fine.
Couldn't tell you why, but the issue appears to lie with 'customizeAppearance'. When a horizontal centering layout constraint is used, customizeAppearance is called before frames and bounds are set properly. Moving the entire body of customizeAppearance into drawRect (there must be better solution) fixed the problem.
Pretty sure this is a bug in auto layout as I'm seeing the same thing happen with a UIImageView in a completely different view hierarchy when a horizontal layout constraint is applied to it. The layout applied in Interface Builder causes the problem but same layout applied in code (in viewDidLoad of parent view controller) works fine.
Did you ever track this issue down? I have the same issue. Moving customizeAppearance code to drawRect solved it for me, but seems like there must be a cleaner way to fix it.
I never did. After looking into it further, I was under the impression it was an iOS auto layout bug, as a stock UIImageView was running into the same issue. Please let me know if you find out otherwise.
Will do.