HI,
MiTuKit is a lightweight and powerful Swift library designed to accelerate development with UIKit.
It provides a collection of essential classes and extensions, simplifying coding by leveraging inheritance and reusable components.
With MiTuKit, developers can write cleaner and more efficient code, enhancing productivity in iOS projects.
This CocoaPods library is software development kit for iOS, the project depends on 'SnapKit', '~> 5.6.0'
To integrate MiTuKit into your Xcode project using CocoaPods, specify it in your Podfile
:
target 'MyApp' do
pod 'MiTuKit'
end
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift
compiler. It is in early development, but MiTuKit does support its use on supported platforms.
Once you have your Swift package set up, adding MiTuKit as a dependency is as easy as adding it to the dependencies
value of your Package.swift
.
dependencies: [
.package(url: "https://github.com/hominhtuong/MiTuKit.git", .upToNextMajor(from: "1.0.0"))
]
The code would look like this:
import MiTuKit
//Add button to view
let helloButton = UIButton()
helloButton >>> view >>> { //Add button to view then return this button in block
$0.snp.makeConstraints {
$0.top.equalTo(topSafe).offset(16)
$0.centerX.equalToSuperview()
$0.height.equalTo(39)
$0.width.equalTo(343)
}
$0.setTitle("Hello", for: .normal)
$0.setTitleColor(.link, for: .normal)
$0.font = .bold(18)
$0.setImage(UIImage(named: "imageName"), for: .normal)
$0.handle {
print("button tapped!")
}
}
TextField with custom style:
import MiTuKit
let userNameTextField = TTextField()
userNameTextField >>> view >>> {
$0.snp.makeConstraints {
$0.top.equalTo(helloButton.snp.bottom).offset(32)
$0.leading.equalToSuperview().offset(16)
$0.trailing.equalToSuperview().offset(-16)
$0.height.equalTo(50)
}
$0.placeholder = "Enter Username"
$0.eventHandle(for: .editingDidBegin) {
self.userNameTextField.text = ""
}
$0.editingChangedHandle {
let text = userNameTextField.text ?? ""
print(text)
}
$0.editingDidEndHandle {
guard let username = userNameTextField.text else {return}
print("username: \(username)")
}
}
CollectionView and TableView like this:
import MiTuKit
//MARK: - Add to view
collectionView >>> view >>> {
$0.snp.makeConstraints {
$0.edges.equalToSuperview()
}
$0.backgroundColor = .from("0268FF")
$0.registerReusedCell(AnyCollectionViewCell.self)
$0.delegate = self
$0.dataSource = self
}
//MARK: - In Cell
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusable(cellClass: AnyCollectionViewCell.self, indexPath: indexPath)
let item = items[indexPath.item]
cell.configs(item)
return cell
}
MiTuKit is released under the MIT license. See LICENSE for details.
My website: Visit