Syntactic sugar for class object, especially for UIKit UI components.
- Simplify Your Code: Neat helps you quickly set up class objects by removing boilerplate code.
- Avoid Errors: Method chaining reduces the possibility of mistakes.
- Improve Readability: Chaining properties and methods enhances code readability.
To integrate Neat into your project using Swift Package Manager, add the following dependency to your Package.swift
file:
dependencies: [
.package(url: "https://github.com/gnksbm/Neat.git", branch: "main")
]
Initializes a UILabel with configured properties.
import Neat
let label = UILabel().nt.configure {
$0.text("Neat")
.font(.systemFont(ofSize: 17, weight: .semibold))
.textColor(.black)
.backgroundColor(.white)
}
This is equivalent to:
let label: UILabel = {
let label = UILabel()
label.text = "Neat"
label.font = .systemFont(ofSize: 17, weight: .semibold)
label.textColor = .black
label.backgroundColor = .white
return label
}()
let button = UIButton().nt.configure {
$0.configuration(.plain())
.configuration.image(UIImage(systemName: "circle"))
.configuration.baseForegroundColor(.secondaryLabel)
.layer.cornerRadius(10)
.layer.borderWidth(1)
}
lazy var button = UIButton().nt.configure {
$0.setTitle("Neat", for: .normal)
.setTitleColor(.red, for: .normal)
.setImage(UIImage(systemName: "star"), for: .normal)
.addTarget(self, action: #selector(buttonTapped), for: .touchUpInside)
}
let tableView = UITableView().nt.configure {
$0.register(UITableViewCell.self)
}
let view = UIView().nt.configure {
$0.perform {
// Perform any direct operations on the base object.
$0.becomeFirstResponder()
$0.yourMethod()
}
}
Neat is licensed under the MIT License - see the LICENSE file for details.