Let me lay something out there. (Pun intended) Auto layout sucks like a hangover on release day.

I’ve always been a proponent of using tools to make my life easier. I recently discovered PureLayout. Let me say, it’s freaking awesome.

It’s essentially just a wrapper and a more friendly API around iOS’s auto layout API. In the last 12 months as I’ve been learning and incorporating auto layout into my UI development, I’ve sort of created my own auto layout wrapper API. But, it was something I just expanded on as needed and never really polished.

In comes PureLayout. I spent some time trying it out and I now think I’ll go ahead and scrap my own wrapper API and switch totally to this.

I thought I’d show the progression of the same code as it moved from using explicitly the iOS autolayout API with my wrapper API, then to PureLayout. It’s pretty sweet.

My wrapper API

- (void)setToolbarToStandardWidth {
    self.viewsDictionary = @{@"toolbar" : self};
    [self addWidthConstraint:self viewName:@"toolbar"];
}

- (void)addWidthConstraint:(UIView *)view viewName:(NSString *)viewName {
    [view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:[NSString stringWithFormat:@"H:[%@(%i)]", viewName, [UIScreen mainScreen].bounds.size.width]
                                                                 options:0
                                                                 metrics:nil
                                                                   views:self.viewsDictionary]];
}

PureLayout

[self.pinPlaceholderView autoSetDimension:ALDimensionWidth toSize:[UIScreen mainScreen].bounds.size.width];

What I love about it is you don’t have to keep that dictionary of views or even think about it. You don’t have to deal with the visual format syntax. And you just get much more readability. Love.

Swift - Child of the LLVM

Exploring what Swift achieves on LLVM that Obj-C could not. Continue reading

Understanding The LLVM - Introduction

Published on June 18, 2017

Developing for Hardware & Visibility

Published on May 24, 2017