Skip to content

chris-swift-dev/UIKit-Modifiers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UIKit-Modifiers

Swift 5.1 Platform Current Version 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

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

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

.package(url: "https://github.com/crelies/UIKit-Modifiers.git", from: "0.1.0")

About

SwiftUI-like modifiers for many UIKit views and controls

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages