Update simulator
SketchKit is a lightweight, powerful and pure-Swift auto layout library, you can set up your constraints with a simple and intuitive code without any stringly typing.
In short, it allows you to replace this:
newView.translatesAutoresizingMaskIntoConstraints = false addConstraint(NSLayoutConstraint( item: newView, attribute: NSLayoutConstraint.Attribute.centerX, relatedBy: NSLayoutConstraint.Relation.equal, toItem: view, attribute: NSLayoutConstraint.Attribute.centerX, multiplier: 1, constant: 0))
or
newView.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true
with this
// It's NOT necessary: newView.translatesAutoresizingMaskIntoConstraints = false newView.layout.applyConstraint { view in view.centerXAnchor(equalTo: self.view.centerXAnchor) view.centerYAnchor(equalTo: self.view.centerYAnchor) }
To integrate SketchKit into your Xcode project using CocoaPods, specify it in your Podfile:
Podfile
target '<Your Target Name>' do pod 'SketchKit' end
Then, run the following command:
$ pod install
To add SketchKit as a dependency, you have to add it to the dependencies of your Package.swift file and refer to that dependency in your target.
SketchKit
dependencies
Package.swift
target
import PackageDescription let package = Package( name: "<Your Product Name>", dependencies: [ .package(url: "https://github.com/dogo/SketchKit", .upToNextMajor(from: "1.0.0")) ], targets: [ .target( name: "<Your Target Name>", dependencies: ["SketchKit"]), ] )
After adding the dependency, you can fetch the library with:
$ swift package resolve
github "dogo/SketchKit"
import SketchKit final class MyViewController: UIViewController { let myView: UIView = { let view = UIView(frame: .zero) view.color = .red return view }() override func viewDidLoad() { super.viewDidLoad() self.view.addSubview(myView) myView.layout.applyConstraint { view in view.topAnchor(equalTo: self.view.topAnchor) view.leadingAnchor(equalTo: self.view.leadingAnchor) view.bottomAnchor(equalTo: self.view.bottomAnchor) view.trailingAnchor(equalTo: self.view.trailingAnchor) } } }
The project documentation can be found (here)
SketchKit is released under the MIT license. See LICENSE for details.
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
SketchKit is a lightweight, powerful and pure-Swift auto layout library, you can set up your constraints with a simple and intuitive code without any stringly typing.
In short, it allows you to replace this:
or
with this
Requirements
Installation
CocoaPods
To integrate SketchKit into your Xcode project using CocoaPods, specify it in your
Podfile
:Then, run the following command:
Swift Package Manager (SPM)
To add
SketchKit
as a dependency, you have to add it to thedependencies
of yourPackage.swift
file and refer to that dependency in yourtarget
.After adding the dependency, you can fetch the library with:
Carthage
Usage
Quick Start
Documentation
The project documentation can be found (here)
Credits
License
SketchKit is released under the MIT license. See LICENSE for details.