Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mnkgitbox/uikitchain
Using the UIKitChain framework, You can create a UIKit component in one line of code.
https://github.com/mnkgitbox/uikitchain
programatically swift uikit uikit-components uikit-framework uiview uiview-extension
Last synced: 4 days ago
JSON representation
Using the UIKitChain framework, You can create a UIKit component in one line of code.
- Host: GitHub
- URL: https://github.com/mnkgitbox/uikitchain
- Owner: MnkGitBox
- License: mit
- Created: 2022-01-16T17:31:19.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-12T05:45:46.000Z (about 3 years ago)
- Last Synced: 2024-12-24T03:20:41.459Z (about 2 months ago)
- Topics: programatically, swift, uikit, uikit-components, uikit-framework, uiview, uiview-extension
- Language: Swift
- Homepage:
- Size: 2.49 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://cocoapods.org/pods/UIKitChain)
[](https://cocoapods.org/pods/UIKitChain)
[](https://cocoapods.org/pods/UIKitChain)
Using the UIKitChain framework, You can create a UIKit component in one line of code.
### Installation
#### CocoaPods
[CocoaPods](https://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:```ruby
$ gem install cocoapods
```
To integrate UIKitChain into your Xcode project using CocoaPods, specify it in your Podfile:```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '12.0'
use_frameworks!target '' do
pod 'UIKitChain', '~> 1.0.0'
end
```
Then, run the following command:
```ruby
$ pod install
```#### Swift Package Manager
[Swift Package Manager](https://swift.org/package-manager/) is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
> Xcode 11+ is required to build UIKitChain using Swift Package Manager.
```Swift
dependencies: [
.package(url: "https://github.com/MnkGitBox/UIKitChain.git", .upToNextMajor(from: "1.0.0"))
]
```#### Manually
If you prefer not to use either of the aforementioned dependency managers, you can integrate UIKitChain into your project manually.
---
### Usage
Call the `.chain` method right after initializing the UI element. Then you can configure the element using dot notation and finally call `.component` to get your complete view element.
- Without UIKitChain
```Swift
let circleView = UIView()
circleView.backgroundColor = .green
circleView.layer.cornerRadius = 50
circleView.layer.borderColor = UIColor.black.cgColor
circleView.layer.borderWidth = 1
circleView.clipsToBounds = true
circleView.translatesAutoresizingMaskIntoConstraints = false
```
- With UIKitChain
```Swift
let circleView = UIView().chain.bgColor(.green).cornerRadius(50).clipToBounds(true).border(.black).activeAutoConstrant(false).component
```### Add Missing Method or Variable
If there is any missing method or variable, You can add by extending the `UIKitChain` with the corresponding *UIKit element*.
```Swift
extension UIKitChain where Component: UIView {
@discardableResult
func roundView() -> Self {
component.layer.cornerRadius = component.bounds.height/2
return self
}
}
```
### ResourcesYou can find the original sample code [here](SampleCode.swift).
## Credits
- Malith Nadeeshan ([malithnadeeshan](https://twitter.com/malithnadeeshan))## License
UIKitChain is released under the MIT license. See LICENSE for details.