Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crelies/uikit-modifiers
SwiftUI-like modifiers for many UIKit views and controls
https://github.com/crelies/uikit-modifiers
ios modifiers swift swiftui uikit
Last synced: 3 months ago
JSON representation
SwiftUI-like modifiers for many UIKit views and controls
- Host: GitHub
- URL: https://github.com/crelies/uikit-modifiers
- Owner: crelies
- License: mit
- Created: 2019-12-19T22:19:54.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-21T10:03:27.000Z (almost 5 years ago)
- Last Synced: 2024-11-02T07:42:07.009Z (3 months ago)
- Topics: ios, modifiers, swift, swiftui, uikit
- Language: Swift
- Homepage:
- Size: 53.7 KB
- Stars: 21
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# UIKit-Modifiers
[![Swift 5.1](https://img.shields.io/badge/swift5.1-compatible-green.svg?longCache=true&style=flat-square)](https://developer.apple.com/swift)
[![Platform](https://img.shields.io/badge/platform-iOS%20%7C%20macOS%20%7C%20tvOS-lightgrey.svg?longCache=true&style=flat-square)](https://www.apple.com)
[![Current Version](https://img.shields.io/github/v/tag/crelies/UIKit-Modifiers?longCache=true&style=flat-square)](https://github.com/crelies/UIKit-Modifiers)
[![License](https://img.shields.io/badge/license-MIT-lightgrey.svg?longCache=true&style=flat-square)](https://en.wikipedia.org/wiki/MIT_License)*SwiftUI-like* **modifiers** for many **UIKit** *views* and *controls* - **syntactic sugar**, nothing more 🎁
**Let me know if you miss something** 😉
**Hint: *To avoid conflicts with existing functions I had to use different function signatures for some modifiers!***
## Modifiers available for
The modifiers are added through *Extensions* to the views / controls.
| **View** | **Status** |
| --------------------------------- | ---------- |
| **UIActivityIndicatorView** | ✅ |
| **UIButton** | ✅ |
| **UICollectionView** | ✅ |
| **UIControl** | ✅ |
| **UIDatePicker** | ✅ |
| **UIImageView** | ✅ |
| **UILabel** | ✅ |
| **UIPageControl** | ✅ |
| **UIPickerView** | ✅ |
| **UIProgressView** | ✅ |
| **UIScrollView** | ✅ |
| **UISearchTextField** | ✅ |
| **UISegmentedControl** | ✅ |
| **UISlider** | ✅ |
| **UIStackView** | ✅ |
| **UIStepper** | ✅ |
| **UISwitch** | ✅ |
| **UITableView** | ✅ |
| **UITextField** | ✅ |
| **UITextField-UITextInputTraits** | ✅ |
| **UITextView** | ✅ |
| **UITextView-UITextInputTraits** | ✅ |
| **UIView** | ✅ |## Example
If you create your *views in code* you may find yourself writing something similar to
```swift
var textField: UITextField = {
let textField = UITextField()
textField.translatesAutoresizingMaskIntoConstraints = false
textField.placeholder = "Username"
textField.textColor = .systemBlue
textField.font = .systemFont(ofSize: 17, weight: .semibold)
textField.textContentType = .username
return textField
}()
```With this *Swift package* you can use *SwiftUI-like* **modifiers**
```swift
var textField: UITextField = {
UITextField()
.translatesAutoresizingMaskIntoConstraints(false)
.placeholder("Username")
.textColor(.systemBlue)
.font(.systemFont(ofSize: 17, weight: .semibold))
.textContentType(.username)
}()
```**Enjoy adding some *syntactic sugar* on top of your *UIKit code*** 🚀
## Installation
Add this **Swift package** as a dependency to your *Package.swift*
```swift
.package(url: "https://github.com/crelies/UIKit-Modifiers.git", from: "0.1.0")
```