4 ms·
Why not just use Auto Layout in pure code? buttonView = [[UIButton alloc] init]; buttonView.translatesAutoresizingMaskIntoConstraints = NO; [self.view addSub
by agildehaus 13y ago
Why not just use Auto Layout in pure code?
buttonView = [[UIButton alloc] init];
buttonView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:buttonView];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:buttonView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeBottom multiplier:1.0f constant:0.0f]];
... etc
It's certainly better than the stress you'll have with UIView+Positioning or IB.
- smileyborg 13y agoApple's options for Auto Layout in code aren't the best. Check out some of the fantastic third party APIs available. I'm the developer of UIView+AutoLayout, which is designed to provide the API that Apple should have in the first place (it's inspired heavily by the IB options): https://github.com/smileyborg/UIView-AutoLayout https://github.com/smileyborg/UIView-AutoLayout
- vially 13y agoDamn, I was just getting ready to write a comment recommending UIView+AutoLayout to steal some karma from iOS developers who are not using it yet. Seriously though, thanks for this! It really makes working with AutoLayout so much easier.
- cschneid 13y agoI've used a similar one myself. Same name but different project: https://github.com/jrturton/UIView-Autolayout/blob/master/Source/UIView%2BAutoLayout.h https://github.com/jrturton/UIView-Autolayout/blob/master/So... Thank you for making this area of ios dev less painful. :)
- wattson12 13y agoAgreed, I've been using https://github.com/dkduck/FLKAutoLayout https://github.com/dkduck/FLKAutoLayout to simplify the constraint creation