Latest 1.2.0
Homepage https://github.com/cocodelabs/NSAttributedString-CCLFormat
License BSD
Platforms osx 10.6, ios 4.3, watchos 2.0, tvos 9.0, requires ARC
Authors

Build Status
Coverage Status

An extension to NSAttributedString for creating attributed strings by using a
given format string as a template into which the remaining argument values are
substituted. This is helpful for using in conjunction with internationalisation.

@interface NSAttributedString (CCLFormat)

+ (NSAttributedString *)attributedStringWithFormat:(NSString *)format, ...;

@end

Usage

NSAttributedString *blue, *green, *never, *result;

blue = [[NSAttributedString alloc] initWithString:@"Blue" attributes:@{
    NSFontAttributeName: [UIFont boldSystemFontOfSize:16.0f],
    NSForegroundColorAttributeName: [UIColor blueColor],
}];

green = [[NSAttributedString alloc] initWithString:@"Green" attributes:@{
    NSFontAttributeName: [UIFont boldSystemFontOfSize:16.0f],
    NSForegroundColorAttributeName: [UIColor greenColor],
}];

never = [[NSAttributedString alloc] initWithString:@"never" attributes:@{
    NSStrikethroughStyleAttributeName: @(NSUnderlineStyleSingle),
}];

result = [NSAttributedString attributedStringWithFormat:@"%@ and %@ must %@ be seen", blue, green, never];

Installation

CocoaPods is the recommended way to add
NSAttributedString+CCLFormat to your project.

Here’s an example podfile that installs NSAttributedString+CCLFormat.

Podfile

pod 'NSAttributedString+CCLFormat'

License

NSAttributedString+CCLFormat is released under the BSD license. See LICENSE.

Latest podspec

{
    "name": "NSAttributedString+CCLFormat",
    "version": "1.2.0",
    "license": "BSD",
    "summary": "Attributed string extension for creating attributed strings from a format string.",
    "description": "Attributed string extension for creating attributed strings by using a given format as a template into which the remaining argument values are substitued.",
    "homepage": "https://github.com/cocodelabs/NSAttributedString-CCLFormat",
    "authors": {
        "Kyle Fuller": "[email protected]"
    },
    "social_media_url": "https://twitter.com/kylefuller",
    "source": {
        "git": "https://github.com/cocodelabs/NSAttributedString-CCLFormat.git",
        "tag": "1.2.0"
    },
    "requires_arc": true,
    "platforms": {
        "osx": "10.6",
        "ios": "4.3",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "source_files": "NSAttributedStringFormat/NSAttributedString+CCLFormat.{h,m}"
}

Pin It on Pinterest

Share This