Latest 1.0.1
Homepage https://github.com/touyu/SwiftyAttributedString
License MIT
Platforms ios 8.0
Authors

SwiftyAttributedString

Swift 4.2.1

SwiftyAttributedString
SwiftyAttributedString

SwiftyAttributedString

SwiftyAttributedString

Features

  • [x] Comfortable NSAttributedString
  • [x] Better autocompletion
  • [x] Easy range specification
  • [x] Chainable methods
  • [x] Customizable

Installation

Carthage

Add the following line to Cartfile:

github "touyu/SwiftyAttributedString"

Create framework:

$ carthage update --platform iOS

CocoaPods

Add the following line to Podfile:

pod 'SwiftyAttributedString'

Enter the following command at the terminal:

$ pod install

Example

textView.attributedText = "SwiftyAttributedString"
        .attr
        .font(.systemFont(ofSize: 30))
        .range(of: "Swifty") {
            $0.foregroundColor(.blue)
        }
        .range(of: "Attributed") {
            $0.foregroundColor(.red)
            $0.underlineStyle(.single)
        }
        .range(of: "String") {
            $0.foregroundColor(.orange)
            $0.font(.boldSystemFont(ofSize: 30))
        }
        .apply()

SwiftyAttributedString

Documentation

All Range

"SwiftyAttributedString"
         .attr
         .font(.systemFont(ofSize: 30)) // All range
         .apply()

The Specific Range

"SwiftyAttributedString"
         .attr
         .range(start: 0, end: 3) {
              $0.font(.systemFont(ofSize: 30)) // The specific range
         }
         .apply()

Customize

"SwiftyAttributedString"
    .attr
    .customize()
    .apply()

extension SwiftyAttributedString {
    func customize() -> SwiftyAttributedString {
        return font(.systemFont(ofSize: 30))
        .range(of: "Swifty") {
            $0.foregroundColor(.blue)
        }
        .range(of: "Attributed") {
            $0.foregroundColor(.red)
            $0.underlineStyle(.single)
        }
        .range(of: "String") {
            $0.foregroundColor(.orange)
            $0.font(.boldSystemFont(ofSize: 30))
        }
    }
}

Latest podspec

{
    "name": "SwiftyAttributedString",
    "version": "1.0.1",
    "summary": "The library that makes AttributedString easy to use",
    "description": "- Comfortable NSAttributedStringn- Better autocompletionn- Easy range specificationn- Chainable methods",
    "homepage": "https://github.com/touyu/SwiftyAttributedString",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "touyu": "[email protected]"
    },
    "source": {
        "git": "https://github.com/touyu/SwiftyAttributedString.git",
        "tag": "1.0.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "SwiftyAttributedString/**/*.swift"
}

Pin It on Pinterest

Share This