Supports adding text effects or click events and text effect events

Source: Internet
Author: User

Supports adding text effects or click events and text effect events

Source code WPAttributedMarkup. WPAttributedMarkup can add text effects or click events to a keyword in the Label. A keyword in the Label can change the font features, such as color, bold, and underline. You can also add click events for a keyword.
<Ignore_js_op>
Usage:


You can set the label attributes after creating different styles. For example:
// Example using fonts and colours
NSDictionary * style1 =@ {@ "body": [UIFont fontWithName: @ "HelveticaNeue" size: 18.0],
@ "Bold": [UIFont fontWithName: @ "HelveticaNeue-Bold" size: 18.0],
@ "Red": [UIColor redColor]};

// Example using arrays of styles, dictionary attributes for underlining and image styles

NSDictionary * style2 =={ @ "body ":
@ [UIFont fontWithName: @ "HelveticaNeue-Bold" size: 18.0],
[UIColor darkGrayColor],
@ "U": @ [UIColor blueColor],
@ {NSUnderlineStyleAttributeName: @ (kCTUnderlineStyleSingle | kCTUnderlinePatternSolid )}
],
@ "Thumb": [UIImage imageNamed: @ "thumbIcon"]};


// Example using blocks for actions when text is tapped. Uses the 'link' attribute to style the links

NSDictionary * style3 =@ {@ "body": [UIFont fontWithName: @ "HelveticaNeue" size: 22.0],
@ "Help": [WPAttributedStyleAction styledActionWithAction: ^ {
NSLog (@ "Help action ");
}],
@ "Settings": [WPAttributedStyleAction styledActionWithAction: ^ {
NSLog (@ "Settings action ");
}],
@ "Link": [UIColor orangeColor]};

Self. label1.attributedText = [@ "Attributed Bold Red text" attributedStringWithStyleBook: style1];

Self. label2.attributedText = [@ "[td] Multiple styles text [td]" attributedStringWithStyleBook: style2];

Http://ios.662p.com/thread-2190-1-1.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.