Paint
is an iOS framework that makes adding color to your attributed strings via properties.
Example:
myLabel.attributedText = "Hello, world".white.onBlack
Contents
Installation
CocoaPods
Paint
is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Paint"
Carthage
Paint
is available through Carthage. To install it, simply add the following line to your Cartfile:
github "Astranno/Paint" == 1.0.0
Submodule
If you don't use CocoaPods, you can still add Paint
as a submodule, drag and drop Paint.xcodeproj
into your project, and embed Paint.framework
in your target.
- Drag
Paint.xcodeproj
to your project - Select your app target
- Click the
+
button on theEmbedded binaries
section - Add
Paint.framework
Manual
You can directly drag and drop the needed files into your project, but keep in mind that this way you won't be able to automatically get all the latest Paint
features.
Usage
Setup
Make sure to import Paint
:
import Paint
Color a String
Default Colors
Paint
supports all Apple built in colors.
Use the color property on the string to set the text color and use the onColor property to set the background color.
let coloredString = "Red text on blue background".red.onBlue
Custom Colors
You may use custom colors as well by passing in a UIColor to the customColor or onCustomColor functions.
let coloredString = "Red text on blue background".customColor(UIColor.red).onCustomColor(UIColor.blue)
License
Paint
is available under the MIT license. See the LICENSE file for more info.
Made with