目录

DSClickableURLTextField

NSTextField subclass that does one thing: allow links to be clicked on and opened.

DSClickableURLTextField Example Screenshot

To use this class, all you need to do is set the text field’s attributed string value, with some portion of it being a link, and the text field will do the rest. You’ll get the “pointy hand” cursor over the link, and clicking on it will open that link.

let termsAndPolicy = "[Terms of Service](https://example.com) | [Privacy Policy](https://example.com)"
do {
    label.attributedStringValue = try NSAttributedString(markdown: termsAndPolicy)
} catch {
}

Note that the class only works if it is non-editable and non-selectable. This is setup by default, but I wanted to mention it so nobody wastes time trying to figure out why the text field is acting the way it is.

Forked from DSClickableURLTextField

关于
447.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802032778号