Latest 0.3.2
Homepage https://github.com/nskazakov/MAGNSAttributedStringFormat
License Apache License, Version 2.0
Platforms ios 9.0
Frameworks UIKit
Authors

Version
License
Platform

An extension to NSAttributedString for creating attributed strings by using a
given format string.

Use with attributes to set attributes for the entire string

NSAttributedString.attributedStringWith(attributes: [NSAttributedStringKey : Any], format: NSString, arguments: NSAttributedString...)

Use without attributes to set attributes only for arguments

NSAttributedString.attributedStringWith(format: NSString, arguments: NSAttributedString...)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Usage

one = NSAttributedString(string: "one", attributes: [
NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 23),
NSAttributedStringKey.foregroundColor: UIColor.blue
])

two = NSAttributedString(string: "two", attributes: [
NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 23),
NSAttributedStringKey.foregroundColor: UIColor.green
])

three = NSAttributedString(string: "three", attributes: [
NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 23),
NSAttributedStringKey.foregroundColor: UIColor.red
])

etc = NSAttributedString(string: "etc", attributes: [
NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 23),
NSAttributedStringKey.foregroundColor: UIColor.gray
])

result = NSAttributedString.attributedStringWith(format: "You can multiple (%@, %@, %@, %@) arguments with their attributes each of them", arguments: one, two, three, etc)

Installation

MAGNSAttributedStringFormat is available through CocoaPods. To install
it, simply add the following line to your Podfile:

Podfile

pod 'MAGNSAttributedStringFormat'

Author

Nikita Kazakov, [email protected]

License

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

Latest podspec

{
    "name": "MAGNSAttributedStringFormat",
    "version": "0.3.2",
    "summary": "You can add multiple attributes string at the same time",
    "description": "'An extension to NSAttributedString for creating attributed strings by using angiven format string as a template into which the remaining argument values arensubstituted. This is helpful for using in conjunction with internationalisation.'",
    "homepage": "https://github.com/nskazakov/MAGNSAttributedStringFormat",
    "license": {
        "type": "Apache License, Version 2.0",
        "file": "LICENSE"
    },
    "authors": {
        "Nikita Kazakov": "[email protected]"
    },
    "source": {
        "git": "https://github.com/nskazakov/MAGNSAttributedStringFormat.git",
        "tag": "0.3.2"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "MAGNSAttributedStringFormat/Classes/**/*",
    "frameworks": "UIKit",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This