Latest 1.0.0
Homepage https://github.com/samvoigt/TASTaggedAttributedString
License MIT
Platforms ios 5.0, requires ARC
Authors

TASTaggedAttributedString

A category on NSString for quickly generated attributed strings from HTML-style tags.

Basics:

Opening Tags: <>

Closing Tags: </>

Multiple commands can be used in a single tag. For example: <b, i, u>.
These should be comma seperated. Commands are closed by listing them in a
closing tag: </b, i, u>

For commands that take an arguement, an equals sign with no quotes are required. For example:
<c=red, font=Georgia>

Commands are parsed linearly, and not nested. Each new command will override
previous commands. For exmaple, "<c=red>Hello <c=blue>World</c>!" will result
in a red "Hello", blue "World", and a black (uncolored) "!".

Fonts and colors can be described in a nil terminated list using
attributedStringFromTaggedStringWithFontsAndColors. They should be of type
UIFont and UIcolor. The fonts and colors can be referenced by their position
by type in the list using @1, @2, etc. For example, if you pass (in order)
myFont1, myColor1, myFont2, myFont3, myColor2, then those can be accessed by
[email protected], [email protected], [email protected], [email protected], [email protected] respectively. For example: [@"<[email protected]>Hello World</font>" attributedStringFromTaggedStringWithFontsAndColors:myFont];

Color Commands:

  • c=, cf= – Foreground Text Color
  • cb= – Background Text Color
  • tc= – Strikethrough Color

Font Color:

  • family= – Set the family name for a font. Use family= to set a font that can
    be bolded, italicized, or bold ital. Bold, italic, and bold italic are only
    availiable if a family has been set. The default family is HelveticaNeue.
    This must match a family name in the project.
  • face= – Set Font Face. This must match a font name in the project.
  • b – Bold (must have set a family).
  • i – Italic (must have set a family).
  • s= – Size (float value).

Alignment:

  • a= – Options: left, right, center, justified, natural.

Underline:

  • u – Underlines text

Strikethrough:

  • t – Strikethrough text. The line will be the same color as the current text
    color, unless the strikethrough color has been specified (see above).

Latest podspec

{
    "name": "TASTaggedAttributedString",
    "version": "1.0.0",
    "summary": "A category on NSString for quickly generating attributed strings from HTML-style tags.",
    "description": "NSAttributedStrings are quite useful in UILabels and UITextViews, however they're not particularly user-friendly, especially with dynamic text. TaggedAttributedString is a simple way to generate NSAttributedStrings using lightweight HTML-style tags, and makes using NSAttributedStrings far less painful.",
    "homepage": "https://github.com/samvoigt/TASTaggedAttributedString",
    "license": {
        "type": "MIT",
        "file": "LICENSE.txt"
    },
    "authors": {
        "Sam Voigt": "[email protected]"
    },
    "platforms": {
        "ios": "5.0"
    },
    "source": {
        "git": "https://github.com/samvoigt/TASTaggedAttributedString.git",
        "tag": "1.0.0"
    },
    "source_files": "TASTaggedAttributedString/*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This