Swiftpack.co - Package - umobi/UICreator


Swift Version License Platform


UICreator is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'UICreator'


Class | Name | Status | Description ----|----|----|----- UIViewController | UICHostingView | ✅ | It is used to host UICreator's View. UINavigationController | UICNavigation | ✅ | It can be used the UICNavigation.Other to use custom navigations. UITabController | UICTab | ✅ | Defines a tab bar with UICTabItem to create the tab views. UICPage | UIPageViewController | 🟡 | Create page views. UIView | UICSpacer | ✅ | It contains a lot of properties from UIView and helps spacing content inside of it. UIStackView | UICStack | ✅ | It has two variation UICVStack and UICHStack. UILabel | UICLabel | ✅ | It shows the text on the screen. UITextField | UICText | ✅ | Is a text that can be edited. UITextView | UICScrollText | ✅ | It is a scrollable text that can be edited. UIScrollView | UICScroll | ✅ | Scrollable content with two variation UICVScroll and UICHScroll. UIImageView | UICImage | ✅ | It shows the image on the screen. UIButton | UICButton | ✅ | It is a view with control settings. UICActivity | UIActivityIndicatorView | ✅ | Use the isLoading to show the indicator. UICPageControl | UIPageControl | ✅ | Works by showing indicator to actual page. -- | UICRounder | ✅ | It is used to set cornerRadius and border layout -- | UICZStack | ✅ | It shows more than one child view. -- | UICViewRepresentable | ✅ | It is used to make UIKit view a UICreator view. UITableView | UICList | 🟡 | It list views using UICRow, UICHeader, UICFooter and UICSection. Only some features are implemented. UICollectionView | UICCollection | ❌ | It list view using UICRow, UICHeader, UICFooter and UICSection. It can be used UICFlow that uses UICollectionFlowLayout. To create the layout to views, use layoutMaker(_:). Only some features are implemented.

Reactive Objects

Object | Status | Description ----|----|----- Value | ✅ | Store value inside view. Using the $ it will turn into a Relay object. Relay | 🟡 | It is used to update view property with sync(_:) or next(_:). There are other special properties like bind(to:), map(_:) and flatMap(_:). It is available some operations with booleans, like self.$isEnabled && self.$isEmpty, resulting in Relay. It needs more methods to be more flexible. Property | 🟡 | Allow the view to change behavior depending on value of UIView. Accessing with $ will return a Relay. It needs to be configurated by calling dynamicProperty(_:) on any view inside the body.

UIKit Wrappers

Object | Status | Description ----|----|---- UICOutlet | ✅ | As a way to store the reference of a view inside ViewCreator. Configurated by calling the as(_:) method on the view inside the body getter.

Imperative Methods

Most functions with callback return UIView as a parameter.

Method | Life Time | Description ----|----|---- onNotRendered(:) | Only once | The callback is called when the UIView will move to superview. onRendered(:) | Only once | It is called when the UIView did move to superview. onInTheScene(:) | Only once | It is called when the UIView did move to window. onLayout(:) | Forever | When uiview layout subviews. onTrait(:) | Forever | When traits changes. onAppear(:) | Forever | When UIView is not hidden or move to hierarchy. onDisappear(_:) | Forever | When UIView is hidden or quit the hierarchy.


Besides calling the methods from ViewCreator protocol, it is allowed to declarative create gestures using the on{Gesture}Maker(_:).

UIGestureRecognized | Class | Method ----|----|---- UITapGestureRecognized | Tap | onTap(:) -- | Touch | onTouch(:) UIHoverGestureRecognized | Hover | onHover(:) UILongPressGestureRecognizer | LongPress | onLongPress(:) UIPanGestureRecognizer | Pan | onPan(:) UIPinchGestureRecognizer | Pinch | onPinch(:) UIRotationGestureRecognizer | Rotation | onRotation(:) UIScreenEdgePanGestureRecognizer | ScreenEdgePan | onScreenEdgePan(:) UISwipeGestureRecognizer | Swipe | onSwipe(_:)


Depending on the view, UIControl works by calling the selector when some event occurs. The Control protocol enable events from view that extends UIControl and provides the onEvent(_:, _:) method. With that, UICText implements the onEditingDidEnd(_:) and other methods from UIControl.

Code Example

Go check this repository UICreator Examples to learn and test the library.

import UICreator
class LandmarkRow: UICView {
    let landmark: Landmark
    init(landmark: Landmark) {
        self.landmark = landmark

    var body: ViewCreator {
        UICSpacer(vertical: 5) {
            UICHStack {
                UICImage(image: self.landmark.image)
                    .height(equalTo: 50)
                    .content(mode: .scaleAspectFill)


brennobemoura, brenno@umobi.com.br


UICreator is available under the MIT license. See the LICENSE file for more info.


Stars: 5


Used By

Total: 0


Version 1.1.0 - 2020-08-21 21:23:16

New features

We are excited to announce some cool features added to the UICreator framework.


This property wrapper is a dynamic variable that returns a Relay when accessed using the $ symbol. It allows to track some values of the UIView and UIAccessibility so the app can behave different depending on the value of the object. To setup Property, it is needed to call in some view inside the body getter the function dynamicProperty(_:).


Available for iOS 13, Apple added to UIKit the context menus for all apps. UICreator allows that implementation using the function .contextMenu(_:) for iOS only.


Available for Swift 5.3, UICApp is a new way to build apps without the UIApplicationDelegate.


  • Added a constant behavior for Relays by calling the static property .constant(_:).
  • Implemented the flatMap operator.


  • Now you can present views dynamically inside the body hierarchy with the .present(_:, content:) method.
  • Push views dynamically using the UICNavigationLink(_:, destination:, content:).

General Improvements

  • Fixed an error on RenderManager when the ViewCreator isn't assign to the UIView.
  • Fixed a fatal error when the Relay tries to set a value where the source Value isn't available anymore.
  • Some ViewCreators were acessing the UIView using force cast operator, in this release that problem was solved.
  • Added more operators in some views.

UICreator release - 2020-07-27 16:12:24

Now you can use UICreator in all our app and rewrite ViewControllers and UIViews

1.0.0 Alpha 10 - Minor Fixes - 2020-05-13 22:56:59


  • Removed dependency to UIContainer
  • Value only holds values and Relay transmits data in a reactive way.
  • Border color now updates when trait changes.
  • The present(animated:, onCompletion:, content:) doesn't need anymore the ViewCreator to be concrete type.
  • Now ContainerController is UICHostingView.
  • You can search for ViewCreators in the UIView hierarchy. Since ViewCreator works as a envelop, sometimes we only have the UIView instance or UIWindow and we want to find a specific view.
  • You can do more with UICTab like to change the tabItem content when the ViewCreator appears.


  • UICList can throw layout errors.
  • UICCollection or UICFlow enter in a loop on layoutSubviews() method.

Future Release

  • It is currently being studied on how to flatten the view hierarchy. In our case of study and with some implementations, the view hierarchy has too many items and some basics contents can be avoided.
  • We may remove UICHost and RootView. On UICHostingView, the idea is to set the view of the controller the same view of ViewCreator.
  • We did some tests with libraries that remove the AutoLayout but sometimes AutoLayout was faster than the solution in the libraries.

Big Changes of Alpha 9 - 2020-04-12 00:08:43

Update Log

  • A fill changes on how RenderManager execute the view handlers on ViewAdaptor
  • ReusableView is not fully developed, but after a lot of tests the better algorithm to reuse views was to not reuse at all. In the future, when this project be more mature, the idea is to develop a reusable algorithm without removing views, but changing the creator associated to it.
  • Moved a lot of view property setters that were in the init of the view creator to the onNotRendered callback.
  • Fixed bugs and errors on old versions of iOS.
  • Added more methods and renamed a lot of functions to be more equal to UIKit properties.
  • Added the TabItem to provide specific methods to personalize the UITabBarItem.
  • Added on Header the estimatedHeight to UICList void constraint layout bugs.
  • Adding constraints to other view was easy before when using reference, but, after a lot of changes on UICreator, the view reference was substitute by UICOutlet that provided a better management of the view. So, when add constraints, the property was changed to be a callback type so it can access the UICOutlet view with no error.
  • Removed dependency to EasyAnchor and added the ConstraintBuilder from Umobi repo.
  • UIViewWrapper helps when it is necessarily to make changes directly in the view and provides methods to mount the UIView declared using UICreator. This should only be used when it is totally necessarily.
  • Improved memory access that was causing errors on swift 5.2 after Xcode updates. Now, there are a lot of methods to UICreator store data in memory. Still there are some objc set but it was removed a lot of them and moved to class storage or struct to be immutable.
  • Constraints gives a lot of layout errors and in the UICreator was no different. In the first project, creator always was adding new constraints when the constraint methods were called. Now, with EasyAnchor, included in the ConstraintBuilder, creator will search for some similar constraint and update or create if needed. So, if there are a lot of .top(equalTo: 5), .top(equalTo: 10), the final result will be only one constraint with 10 as constant to the top of superview.
  • Gestures now implements the Delegate that can be access using the onTapMaker.
  • The same idea used in UIViewWrapper, there is now a NavigationModifier to permit directly access given some view creator.
  • Added support to Swift Package Manager.
  • Added onTrait to be notified when trait changes on some view. With this, when creator set borderColor, it will updates the CGColor when trait changes.
  • Render will now commit the handlers from the bottom to the top views and to the first handler to the last, following the declarated order.

To alpha 9

If you are using alpha 8 or old versions, you may have to change some functions name. All functions associated to UITextView, UILabel and UITextField have some updated. It was renamed and removed the .text(color:) to .textColor(_:). The functions .background(color:), .clips(toBounds:), .shadow(ocupacity:), .shadow(radius:), .shadow(color:), .shadow(offset:), .border(color:), .border(width:), now are .backgroundColor(_:), .clipsToBounds(_:), .shadowOcupacity(_:), .shadowRadius(_:), .shadowColor(_:), .shadowOffset(_:), .borderColor(_:), .borderWidth(_:).