NotSwiftUI Just Got Better — Know How to Use It to Create UI Components in iOS | by Jonathan Gamburg | Apr, 2022

Constructing a greater future for all UIKit lovers, and why investing in it issues

Again in December 2021 I posted this.

Primarily created my very own SwiftPackage and effectively.. marketed it slightly. The bundle, which is conveniently named NotSwiftUI, was constructed on the core concept that all the UI parts that are offered by UIKit are basically UIViews. From the only UIView, UIButton, or a UILabel all the best way as much as a UITextField, UITextView, UISwitch, and even a UIStackView.

NotSwiftUI supplied a novel strategy to declare new parts and use all these UI parts in a handy and even, some may add — a enjoyable method. Not solely declaring and creating these parts was simpler but in addition making use of varied results and configurations similar to making use of a shadow, including a border with a coloration, performing an animation, clipping the view to its bounds, including a goal, including a contact gesture, setting an attributed string and extra…The record actually simply goes on and on.

Declaring a button with varied attributes

Having labored with SwiftUI you’re ought to search out bugs or “options”. Sure components of the framework really feel at instances “incomplete” and varied strategies to realize the wished outcome may even really feel “hacky”.

SwiftUI is nice, and don’t get me incorrect, I do see it as the longer term — however — it’s nonetheless removed from being full and dependable. That is naturally my private {and professional} opinion and a few folks might not agree with me. However from my expertise, I simply don’t but really feel totally content material and dedicated to engaged on a large-scale undertaking with SwiftUI.

Regardless of my harsh criticism, SwiftUI does a number of issues proper, particularly when creating UI. The core thought behind NotSwiftUI was to bridge this hole between UIKit and SwiftUI and to permit the developer the liberty to create UI rapidly and effectively while sustaining a readable and easy-to-understand code.

Including some parts to a horizontal UIStackView

The bridging between SwiftUI and UIKit was meant to permit the developer to realize fairly advanced duties utilizing a minimal quantity of code whereas sustaining readability. It’s all meant to save lots of time. Loads of time goes on fixing views in varied locations, connecting actions, including gesture recognizers, including animations, and so forth.

With NotSwiftUI the primary thought was to permit the developer to do all this rapidly and in fewer strains of code. And as every part is a UIView, every part works on every part, and if it doesn’t then nothing occurs.

Since December a number of issues have occurred. I grew to become extra skilled in my area and so has NotSwiftUI. I’ve made positive to try to incorporate NotSwiftUI in my initiatives too. Thus adapting it for extra numerous makes use of.

Consequently, in the present day you’ll be able to do extra with NotSwiftUI than ever. You’ll be able to carry out animations, add targets for buttons (or as a UITapGesture) as closures, play with attributed Strings in labels, textual content fields, textual content views and buttons, creating extra UI parts and far more.

A button which upon tapping it might change its title with an animation
The outcome

NotSwiftUI is evolving continuously. However as time goes on extra options will probably be added and I as an individual who nonetheless believes that SwiftUI has but reached its mature kind however nonetheless want to have enjoyable with its declarative nature, NotSwiftUI tries to attach the 2 worlds collectively as seamlessly as doable.

Go forward, attempt it, experiment, and depart suggestions (it is necessary!), NotSwiftUI is right here for all, to make lives simpler, extra enjoyable, and satisfying!

More Posts