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

Automatically Detected Views

Custom Views


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




Last updated
import UIKit
class ProfilePageViewController: UIViewController {
// MARK: - Properties
@IBOutlet private weak var rectangleView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
setupViews()
setupLayout()
}
}
extension ProfilePageViewController {
private func setupViews() {
rectangleView.layer.cornerRadius = 6
rectangleView.layer.masksToBounds = true
rectangleView.backgroundColor = UIColor.cloudBlue
}
private func setupLayout() {
//Constraints are defined in Storyboard file.
}
}<!--activity_profile_page.xml-->
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ProfilePageActivity"
android:background="?attr/daisy">
<View
android:id="@+id/containerView"
android:layout_width="78dp"
android:layout_height="26dp"
android:background="@drawable/baseview_background_drawable"
android:layout_marginEnd="56dp"
android:layout_marginTop="42dp"
android:layout_marginBottom="37dp"
app:layout_constraintStart_toEndOf="@+id/profilPictureImageView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/nolanAlexTextView"
app:layout_constraintBottom_toTopOf="@+id/alexanderNolanTextView"/>
</androidx.constraintlayout.widget.ConstraintLayout><!--Drawables/containerview_background_drawable.xml-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="?attr/cerulean"/>
<corners android:radius="6dp"/>
</shape>
</item>
</selector>import UIKit
class FormItemView: UIView {
// MARK: - ContentView
@IBOutlet weak var view: UIView!
// MARK: - Properties
@IBOutlet private weak var usernameLabel: UILabel!
@IBOutlet private weak var emailTextField: FormTextField!
// MARK: - Initializers
override init(frame: CGRect) {
super.init(frame: frame)
initialize()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
initialize()
}
init() {
super.init(frame: .zero)
initialize()
}
func initialize() {
initializeNib()
applyDefaultStyle()
}
func initializeNib() {
Bundle.main.loadNibNamed(String(describing: type(of:self)), owner: self, options: nil)
addSubview(view)
view.frame = self.frame
view.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
self.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0),
self.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0),
self.topAnchor.constraint(equalTo: view.topAnchor, constant: 0),
self.bottomAnchor.constraint(lessThanOrEqualTo: view.bottomAnchor, constant: 0),
])
}
// MARK: - Styling
func applyDefaultStyle() {
usernameLabel.textColor = UIColor.black
usernameLabel.numberOfLines = 0
usernameLabel.font = UIFont.textStyle5
usernameLabel.textAlignment = .left
emailTextField.set(placeholder: NSLocalizedString("travel.lover", comment: ""))
}
func set(usernameLabelText: String, emailTextFieldPlaceholder: String){
usernameLabel.text = usernameLabelText
emailTextField.placeholder = emailTextFieldPlaceholder
}
}