给UITextView添加链接
- NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:@"This is an example by @marcelofabri_"];
- [attributedString addAttribute:NSLinkAttributeName
- value:@"username://marcelofabri_"
- range:[[attributedString string] rangeOfString:@"@marcelofabri_"]];
- NSDictionary *linkAttributes = @{NSForegroundColorAttributeName: [UIColor greenColor],
- NSUnderlineColorAttributeName: [UIColor lightGrayColor],
- NSUnderlineStyleAttributeName: @(NSUnderlinePatternSolid)};
- // assume that textView is a UITextView previously created (either by code or Interface Builder)
- textView.linkTextAttributes = linkAttributes; // customizes the appearance of links
- textView.attributedText = attributedString;
- textView.delegate = self;
- - (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange {
- if ([[URL scheme] isEqualToString:@"username"]) {
- NSString *username = [URL host];
- // do something with this username
- // ...
- return NO;
- }
- return YES; // let the system open this URL
- }
给UITextView添加链接的更多相关文章
- sqlserver 多库查询 sp_addlinkedserver使用方法(添加链接服务器)
sqlserver 多库查询 sp_addlinkedserver使用方法(添加链接服务器) 我们日常使用SQL Server数据库时,经常遇到需要在实例Instance01中跨实例访问Instanc ...
- linux下添加链接与删除链接(ln命令的用法)
添加链接使用ln命令用法:#ln --help用法:ln [选项]... 目标 [链接名]或:ln [选项]... 目标... 目录或:ln [选项]... --target-directory=目录 ...
- easyui的datagrid行的某一列添加链接
通过formatter方法给easyui 的datagrid 每行增加操作链接. 效果图 jsp代码: <th field="url" width="100&quo ...
- visual studio 添加链接文件
本文转载http://blog.163.com/zhongpenghua@yeah/blog/static/87727415201282432345613/ 那个有个箭头的文件就是链接文件了,添加 ...
- HTML之学习笔记(六)添加链接
html添加链接所用的标签为<a>标签 语法: 定义:从当前页面,跳转到指定页面或文件的一个标签 <a href="URL">热点文字 ...
- ckeditor自定义插件--一键给所有的图片添加链接
ckeditor自定义插件在网上查了查,感觉还是比较好用的,写了一个一键给编辑器中的所有图片添加链接. 在ckeditor目录下的plugins下建以插件为名的文件夹,在里边建plugin.js文件, ...
- WordPress文章自动提取tag并添加链接
我们在编写文章时,经常需要添加一些标签关键词的链接,这样不仅可以优化我们的内链,对用户来说也可以参照相关的文章,如果对文章的关键字进行手动添加链接,那样对我们来说太麻烦了,而且在标签关键词很多的情况下 ...
- Bootstrap历练实例:向列表组添加链接
向列表组添加链接 通过使用锚标签代替列表项,我们可以向列表组添加链接.我们需要使用 <div> 代替 <ul> 元素.下面的实例演示了这点: <!DOCTYPE html ...
- SQLServer添加链接服务器
右键,添加链接服务器 在安全里面输入用户名和密码 添加成功之后的使用方法 select * from [192.168.1.63,3326].[数据库].[dbo].[表]
随机推荐
- Oracle数据库锁表查询
--查看数据库最大连接数 select value from v$parameter where name = 'processes'; --更改数据库连接数 alter system scope = ...
- jq完成省市区街道四级联动
之前看的省市区街道四级联动的插件,感觉和公司要求的有些不符合,就自己写了一个 因为要读取本地json文件,所以要跑下服务器 下载browser-sync 然后在项目目录下运行browser-sync ...
- 【错误记录】windows python 路径中的一个转义错误:'rawunicodeescape' codec can't decode bytes in position 112-113: truncated \uXXXX
ur"D:\work\结构化\CSV\useful\内容.csv" 报错 编码错误原因,当路径中有\u这种字串时,即使是包含在r"" 中也会进行转义,然后转义出 ...
- springcloud(十七):服务网关 Spring Cloud GateWay 熔断、限流、重试
上篇文章介绍了 Gataway 和注册中心的使用,以及 Gataway 中 Filter 的基本使用,这篇文章我们将继续介绍 Filter 的一些常用功能. 修改请求路径的过滤器 StripPrefi ...
- hbuilderx 连接模拟器
打开cmd,找到bin的安装目录(G:\Program Files\Nox\bin) cd进入夜神模拟器bin目录 执行以下命令 nox_adb connect 127.0.0.1:620 ...
- python之新式类与经典类
经典类与新式类 经典类:P 或 P()--深度查找,向上查父节点 新式类 :P(object)---广度查找,继承object,新式类的方法较多
- Mybaits查询返回值是List类型的
查询返回值是list类型的 1 首先在接口中写方法 public interface EmployeeMapper { public List<Employee> getEmpsByLas ...
- 1443:【例题4】Addition Chains
1443:[例题4]Addition Chains 题解 注释在代码里 注意优化搜索顺序以及最优化剪枝 代码 #include<iostream> #include<cstdio&g ...
- JavaScript函数、BOM
[函数的声明和调用] 1.>>>函数声明的格式:形参可以不用var声明 使用function关键字声明: function 函数名 (参数1,参数2,......){ //函数体 r ...
- linux(centOS7)的基本操作(一) 概述
linux服务器的连接 1.连接 window环境下需要安装XShell.XFtp等软件,暂时不表: macOS环境下直接用ssh命令登录即可,用以下任意一种 ssh [-p port] userna ...