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 !
  • 相关阅读:
    算法复习:字符串
    【第五天打卡。
    【第四天打卡。
    【第三天打卡。
    第二天打卡。
    【唉
    配环境到崩溃系列
    所谓环境……
    【随便吐槽
    第四天。打卡。【偷懒了两天hhhh
  • 原文地址:https://www.cnblogs.com/mogul/p/5146171.html
Copyright © 2011-2022 走看看