Swiftpack.co - FluidGroup/TypedTextAttributes as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by FluidGroup.
FluidGroup/TypedTextAttributes 1.5.0
🖍 The Library Creating Text Attributes with Type-Safety
⭐️ 54
🕓 1 week ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/FluidGroup/TypedTextAttributes.git", from: "1.5.0")

🖍 TypedTextAttributes

Swift4 Release CocoaPods Carthage
Build Status Lincense

The Library Creating Text Attributes with Type-Safety
It will be helpful for creating NSAttributedString.

💡 TypedTextAttributes is inspired by TextAttributes.

Usage

It's very simple sample code.

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<NSAttributedString.Key, Any> So, we can also describe following.

let baseAttributes = [NSAttributedString.Key : Any](https://raw.github.com/FluidGroup/TypedTextAttributes/master/)

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 is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate TypedTextAttributes into your Xcode project using CocoaPods, specify it in your Podfile:

target 'YourApp' do
  pod 'TypedTextAttributes'
end

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate TypedTextAttributes into your Xcode project using Carthage, specify it in your Cartfile:

github "muukii/TypedTextAttributes"

Run carthage update to build the framework and drag the built TypedTextAttributes.framework into your Xcode project.

Author

muukii, muukii.app@gmail.com

License

TypedTextAttributes is available under the MIT license. See the LICENSE file for more info.

GitHub

link
Stars: 54
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1.5.0
1 week ago

What's Changed

Full Changelog: https://github.com/FluidGroup/TypedTextAttributes/compare/1.4.0...1.5.0

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics