Cupcake: an easy way to create and layout UI components for iOS

Boost your productivity, and save your time.


Cupcake is a framework that allow you to easily create and layout UI components for iOS 8.0+. It use chaining syntax and provides some frequent used functionalities that are missing in UIKit.

Easy way to create UIFont, UIImage and UIColor objects

You can create UIFont object with Font() function.

You can create UIImage object with Img() function.

You can create UIColor object with Color() function.

Easy way to create NSAttributedString objects and String manipulations

You can create NSAttributedString object with AttStr() function.

String manipulations:

4 basic UI components

You can create UIView, UILabel, UIImageView and UIButton objects simply by using View, Label, ImageView and Buttonvariables.

As you can see, .font().img() and .color() can take the same parameters as Font(), Img() and Color(). Also you can pass String, NSAttributedString or any other values to .str().


You can add click handler and adjust click area to any view.
To round a view with half height no matter what size it is, simply use .radius(-1).

You can add line spacing and link handling to UILabel.

.bg() allow you to set background for any view with color or image.
.highBg() allow you to set highlighted background for UIButton.
Also you can add spacing to title and image within button or even exchange their position.

You can add placeholder and limit text input to UITextField and UITextView.

Easy way to Setup Constraints

You use .pin() to setup simple constraints relative to self or superview.

You use .makeCons() and .remakeCons() to setup any constraints just like SnapKit.

You use .embedIn() to embed inside superview with edge constriants.

Easy way to Layout

Setup constraints for every views manually could be tedious. Luckily, you can build most of the layouts by simply using HStack() and VStack() (which are similar to UIStackView) and hopefully without creating any explicit constirants.

Lightweight Style

Some of the chainable properties can be set as style.


You can create static tableView with PlainTable() or GroupTable() functions.

You can present Alert And ActionSheet using the chaining syntax as well.


pod "Cupcake"