Skip to content

Getting Started

zhenglibao edited this page Jul 20, 2018 · 7 revisions

FlexLib is a framework for creating native iOS applications using a human-readable markup language, similar to Android and .NET development way.

Get FlexLib

FlexLib is developed as freely open-source project on Github. You can get it through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'FlexLib'

Then import FlexLib.h in your project.pch:

#import <FlexLib/FlexLib.h>

Maybe you will get error when pod install. If so you will need to update your local pod repository. See more here


Basic layout knowledge

<?xml version="1.0" encoding="utf-8"?>

<UIView layout="flex:1,justifyContent:center,alignItems:center" attr="bgColor:white">
  <UIView name="_test" onPress="onPressTest" layout="width:40,height:40" attr="bgColor:lightGray"/>
</UIView>

This demo is small but there are some knowledge you should know.

  • Any UIView descendant in app will be available in xml layout.
  • Every element support four xml attribute: name, onPress, layout, attr.
    • The element with 'name' will be binded to the variable in owner. Warning: It may cause memory leak if the name not exist in owner but declared for the element.
    • 'onPress' will be binded to the method in owner.
    • 'layout' support all the yoga-flexbox attributes like width, margin, padding, flexDirection, ...
    • 'attr' support the view attribute like bgColor, fontSize, color, ...
  • Normally the top view in xml layout should have layout attribute with 'flex:1', so it will fill the whole area.
  • For view controller, the background color of the top view in xml layout will be synchronized to the view of the view controller.
Clone this wiki locally