[Swift] TTTAttributedLabel uses note, tttattributedlabel

Source: Internet
Author: User

[Swift] TTTAttributedLabel uses note, tttattributedlabel


Preface

TTTAttributedLabel is inherited from UILabel and can be easily modified based on the existing code. The Star has exceeded 4 K +. I took some notes today.

 

StatementWelcome to repost, but please keep the original source of the article :) blog Park: http://www.cnblogs.com farmer UNCLE: http://over140.cnblogs.com

 

Environment

Xcode 6.3.3

Cocoapods 0.37.2

 

Body

1. If the Pod directly uses TTTAttributedLabel, an error is reported in the Storyboard. error message:

Directly introduce the source code.

 

2. Add Link

AddLinkToURL (NSURL (string: "https://www.google.com ")!, WithRange: NSString (string: "Welcome to Google"). rangeOfString ("Google "))

Pay attention to the swift syntax. It is not feasible to directly use String. rangeOfString. The NSString method is required.

 

3. Modify the default link style (Retain text color and underline)

Mainly set linkAttributes

Label. linkAttributes = [kCTForegroundColorAttributeName: agreeLabel. textColor, NSUnderlineStyleAttributeName: NSNumber (long: NSUnderlineStyle. StyleSingle. rawValue)]

Here, the label is TTTAttributedLabel.


 

References

TTTAttributedLabel for iOS source code reading

TTTAttributedLabel usage

 

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.