Views

Monday Hero can automatically understand the views, and convert design to Swift/Kotlin code.

View Design to Code

A view expresses a single item on the user interface. It could be a shape like a rectangle, a control item such as a button, an input text field, or an image. A view is a defined specific area on the screen which can be configured to respond to touch events, or it can be used for enriching the user experience.

As can be seen below, the Follow button has designed with a blue rectangle and a text. Monday Hero automatically detected that the blue rectangle/background is a View and the text is a Label. Let's check how Monday Hero detected thisViewand generate its code. The blue rectangle on the image below is detected as Viewand calledcontainerView, the code will be generated like below.

On this page, Viewcode will be explained, detailed info about texts and images can be found on the next pages. Learn more about images here. Learn more about texts here.

Generated iOS/Android Code of the View

The code will be generated like below and constraints are defined in the Storyboard file.

import UIKit

class ProfilePageViewController: UIViewController {
	
	// MARK: - Properties
	@IBOutlet private weak var containerView: UIView!

	override func viewDidLoad() {
		super.viewDidLoad()
		setupViews()
		setupLayout()
	}
}

extension ProfilePageViewController {
	private func setupViews() {

		containerView.layer.cornerRadius = 6
		containerView.layer.masksToBounds =  true 
		containerView.backgroundColor = UIColor.cerulean

	}

	private func setupLayout() { 
		//Constraints are defined in Storyboard file.
	}
}

You can also read and see how these Views become a component together. You can check how to create a button component here.

Last updated