GitHub - shindyu/ApplyStyleKit: Elegant Apply Style by Swift Method Chain.?
source link: https://github.com/shindyu/ApplyStyleKit
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
ApplyStyleKit
ApplyStyleKit is a library that applies styles to UIKit using Swifty Method Chain.
Normally, when applying styles to UIView etc.,it is necessary to write propertyName and equal operator many times.
With ApplyStyleKit, you can comfortably apply style to your code.
Like this:
sampleLabel.applyStyle .backgroundColor(.yellow) .text("sample label") .textAlignment(.center) .textColor(.green) .font(.boldSystemFont(ofSize: 30.0)) .numberOfLines(0)
Installation
Requirements
- iOS 9.0 or later
- Swift 4.2
- Xcode 10
Carthage
github "shindyu/ApplyStyleKit"
CocoaPods
target '<Your Target Name>' do
pod 'ApplyStyleKit', '~> 0.1.0'
end
Usage
import ApplyStyleKit class ViewController: UIViewController { let sampleView = UIView() let sampleLabel = CustomLabel() override func viewDidLoad() { super.viewDidLoad() // Apply style sampleView.applyStyle .backgroundColor(.red) .alpha(0.5) // When applying to layer sampleView.layer.applyStyle .cornerRadius(10) .borderColor(.gray) .borderWidth(2) // Of course, you can apply it if you inherit UIView etc. sampleLabel.applyStyle .text("Of course, you can apply it if you inherit UIView etc.") .textAlignment(.center) .textColor(.green) .font(.boldSystemFont(ofSize: 30.0)) .numberOfLines(0) } }
Support
QuartzCore
- ✅ CALayer
UIKit
- ✅ UIView
- ✅ UILabel
- ✅ UIButton
- ✅ UIImageView
- ✅ UISwitch
- ✅ UIControl
- ✅ UIStackView
Contributing
Please make an issue or pull request if you have any request.
Bug reports, Documentation, or tests, are always welcome as well!?
License
ApplyStyleKit is available as open source under the terms of the MIT License.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK