Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/FluidGroup/TypedTextAttributes
🖍 The Library Creating Text Attributes with Type-Safety
https://github.com/FluidGroup/TypedTextAttributes
ios nsattributedstring swift
Last synced: 3 months ago
JSON representation
🖍 The Library Creating Text Attributes with Type-Safety
- Host: GitHub
- URL: https://github.com/FluidGroup/TypedTextAttributes
- Owner: FluidGroup
- License: mit
- Created: 2018-09-14T19:26:43.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-18T17:14:26.000Z (8 months ago)
- Last Synced: 2024-07-10T15:11:58.691Z (4 months ago)
- Topics: ios, nsattributedstring, swift
- Language: Swift
- Homepage:
- Size: 315 KB
- Stars: 61
- Watchers: 4
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🖍 TypedTextAttributes
**The Library Creating Text Attributes with Type-Safety**
**It will be helpful for creating NSAttributedString.**💡 TypedTextAttributes is inspired by [TextAttributes](https://github.com/delba/TextAttributes).
## Usage
It's very simple sample code.
```swift
let attributedString = "Hello".attributed {
TextAttributes()
.font(UIFont.preferredFont(forTextStyle: .headline))
.foregroundColor(.white)
.alignment(.right)
}
```We can create text-attributes with method chaining.
The methods are defined by extention for `Dictionary`
So, we can also describe following.```swift
let baseAttributes = [NSAttributedString.Key : Any]()let attributes = baseAttributes
.foregroundColor(.white)
.alignment(.right)
```And, `[NSAttributedString.Key : Any]` has typealias as `TextAttributes` in this library.
### The Methods adding attributes
- font
- foregroundColor
- backgroundColor
- underlineStyle
- underlineColor
- strikethroughStyle
- strikethroughColor
- strokeColor
- strokeWidth
- textEffect
- link
- baselineOffset
- obliqueness
- expansion
- verticalGlyphForm
- kern
- paragraphStyle
- alignment
- firstLineHeadIndent
- headIndent
- tailIndent
- lineHeightMultiple
- maximumLineHeight
- lineSpacing
- paragraphSpacing
- paragraphSpacingBefore
- lineBreakMode
- ligature
- attachment
- shadow## Installation
### CocoaPods[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:
```bash
$ gem install cocoapods
```To integrate TypedTextAttributes into your Xcode project using CocoaPods, specify it in your `Podfile`:
```ruby
target 'YourApp' do
pod 'TypedTextAttributes'
end
```Then, run the following command:
```bash
$ pod install
```### Carthage
[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with [Homebrew](http://brew.sh/) using the following command:
```bash
$ brew update
$ brew install carthage
```To integrate TypedTextAttributes into your Xcode project using Carthage, specify it in your `Cartfile`:
```ogdl
github "muukii/TypedTextAttributes"
```Run `carthage update` to build the framework and drag the built `TypedTextAttributes.framework` into your Xcode project.
## Author
muukii, [email protected]
## License
TypedTextAttributes is available under the MIT license. See the LICENSE file for more info.