zoukankan      html  css  js  c++  java
  • 在UITextview中添加链接属性的文字

        let termsAndPrivacyLabel = UITextView(frame: CGRect(x: 24/2, y: 0,  width, height: height))
            let string = "By signing up, you agree to the Terms of Use & Privacy Policy."
            let text = NSMutableAttributedString(string: string, attributes: [NSFontAttributeName: UIFont.systemFontOfSize(11.6)])
            text.addAttribute(NSLinkAttributeName, value: "https://github.com/site/terms", range: NSMakeRange(32, 12))
            text.addAttribute(NSLinkAttributeName, value: "https://github.com/site/privacy", range: NSMakeRange(47, 14))
            termsAndPrivacyLabel.attributedText = text
            termsAndPrivacyLabel.autoresizingMask = .FlexibleWidth
            termsAndPrivacyLabel.backgroundColor = UIColor.clearColor()
            termsAndPrivacyLabel.contentInset.top = 3 // shows the top dot of text-selector bar
            termsAndPrivacyLabel.editable = false
            termsAndPrivacyLabel.scrollEnabled = false
            tableFooterView.addSubview(termsAndPrivacyLabel)
    

     点击该高亮的文字会自动跳转到链接界面

    I am not doing shit today !
  • 相关阅读:
    Python-产生随机长度的密码
    Python-双色球
    Python-产生手机号码
    Word操作笔记
    1035 最长的循环节
    B. Recover the String
    uva11752 The Super Powers
    UVA11754
    GCD
    D. Persistent Bookcase(Codeforces Round #368 (Div. 2))
  • 原文地址:https://www.cnblogs.com/mogul/p/5146171.html
Copyright © 2011-2022 走看看