Open Source Library Extending UIView For Easy Layouts With A CSS Flexbox Style Syntax

Earlier this month I mentioned the Swiftbox library for layouts with a CSS flexbox style syntax.

Here’s a library providing a UIKit extension wrapping flexbox properties within a UIView called FlexboxKit submitted by Alex Usbergo.

FlexboxKit provides a category extending UIView allowing you to set its properties directly with a flexbox type syntax along with any subviews.

This example from the readme shows how one could create a complex layout using FlexboxKit:

contentView.flexDirection = FLEXBOXFlexDirectionRow;

left.flexFixedSize = (CGSize){A_FIXED_SIZE, A_FIXED_SIZE};
left.flexMargin = (UIEdgeInsets){SOME_MARGIN, SOME_MARGIN, SOME_MARGIN, SOME_MARGIN};
left.flexAlignSelf = FLEXBOXAlignmentCenter;

rigth.flexContainer = YES;
right.flex = 1;
right.flexJustifyContent = FLEXBOXJustificationCenter;

time.flexMargin = (UIEdgeInsets){SOME_MARGIN, SOME_MARGIN, SOME_MARGIN, SOME_MARGIN};
time.flexPadding = (UIEdgeInsets){SOME_PADDING, SOME_PADDING, SOME_PADDING, SOME_PADDING};
time.flexAlignSelf = FLEXBOXAlignmentCenter;

Resulting in this layout:

FlexBoxKit

You can find FLexboxKit on Github here.

A nice simple way to make use of the flexbox way of laying out elements.

Original article: Open Source Library Extending UIView For Easy Layouts With A CSS Flexbox Style Syntax

©2015 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.

Leave a Reply

Your email address will not be published. Required fields are marked *