Skip to content

Swift-CoreUI/CoreUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CoreUI

Library to build UI in declarative and functional style. Built on top of UIKit and supports old iOS versions.

import UIKit
import CoreUI

class MyViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()

    addSubview(
      UI.VScrollView(
        contentInset: .vertical(12),
        UI.VStack(
          UI.View(backgroundColor: .red, height: 20),
          UI.Label("Are you sure?", font: .systemFont(ofSize: 24), color: .label),
          UI.Spacer(minHeight: 30),
          UI.HStack(
            spacing: 12,
            UI.Button("Yes").apply { $0.addTarget(self, action: #selector(yesTapped), for: .touchUpInside) },
            UI.Button("No").apply { $0.addTarget(self, action: #selector(noTapped), for: .touchUpInside) }
          )
        ),
        .leading(6), .trailing(-6), .safeTop(0), .safeBottom(0)
      )
    )
  }

}