OC :

    //自定义一个 placeholder 样式的 label
UILabel *placeholder = [UILabel new];
placeholder.text = @"请输入您的评价";
placeholder.numberOfLines = 0;
placeholder.textColor = kColor(153,153,153);
[placeholder sizeToFit];
placeholder.font = kRegularFont(10); UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(15, 143, SCREEN_WIDTH-30, 48)];
textView.backgroundColor = kColor(245,245,245);
textView.textColor = kColor(153,153,153);
textView.font = kRegularFont(10);
[textView setValue:placeholderforKey:@"_placeholderLabel"]; //这句话必须写
[textView addSubview:placeholder]; // 这句话必须写
[self.mainScroll addSubview:textView];

swift:

    let placeholder = UILabel()
placeholder.text = "想反馈的内容打在这里~"
placeholder.numberOfLines = 0
placeholder.textColor = gray(rgb: 202)
placeholder.sizeToFit()
placeholder.font = regularFont(f: 15) textView = UITextView(frame: CGRect(x: 10, y: 10, width: SCREEN_WIDTH - 20, height: 140))
textView.backgroundColor = .white
textView.textColor = gray(rgb: 51)
textView.font = regularFont(f: 15)
textView.setValue(placeholder, forKey: "_placeholderLabel")
textView.addSubview(placeholder)
textView.layer.cornerRadius = 5
textView.clipsToBounds = true
textView.inputAccessoryView = self.addToolBar()
self.view.addSubview(textView)

iOS 为 textView 添加 placeholder的更多相关文章

  1. 为label或者textView添加placeHolder

    Tip:使用textView的代理需要在头文件中加入: <UITextViewDelegate> h文件 @interface FeedbackViewController : UIVie ...

  2. 李洪强iOS开发之带placeHolder的Textview

    李洪强iOS开发之带placeHolder的Textview  01 - 创建工过程,定义全局属性,遵守textview的代理协议  02 - 添加一个textview和一个label 03 - 实现 ...

  3. android textView 添加超链接(两种实现方式)

    在textView添加超链接,有两种方式,第一种通过HTML格式化你的网址,一种是设置autolink,让系统自动识别超链接,下面为大家介绍下这两种方法的实现 在textView添加超链接,有两种方式 ...

  4. 李洪强iOS开发之添加手势

    李洪强iOS开发之添加手势 02 - 添加手势

  5. 给TextView添加超链接的四种方式

    因为在上上篇博客中介绍了SpannableString的使用(SpannableString使用详解),由此想到给TextView添加超链接究竟有多少种方式?经过个人总结,现在一共发现四种,如果还有其 ...

  6. Android(java)学习笔记147:textView 添加超链接(两种实现方式,,区别于WebView)

    1.方式1: LinearLayout layout = new LinearLayout(this); LinearLayout.LayoutParams params = new LinearLa ...

  7. android 为TextView添加边框

    今天需要在TextView上面添加一个边框,但是TextView本身不支持边框,所以只能采用其他方式,在网上查询了一下,主要有三种方式可以实现1.带有边框的透明图片2.使用xml的shape设置3继承 ...

  8. Xamarin iOS教程之添加和定制视图

    Xamarin iOS教程之添加和定制视图 Xamarin iOS用户界面——视图 在iPhone或者iPad中,用户看到的摸到的都是视图.视图是用户界面的重要组成元素.例如,想要让用户实现文本输入时 ...

  9. Android 编程下 TextView 添加链接的一种方式

    通过如下这种方式给 TextView 添加的链接支持链接样式.点击事件.href 样式,代码如下: package cn.sunzn.tlink; import android.app.Activit ...

  10. 向IOS模拟机上添加图片

    [问题] 折腾: 关于iOS/iPhone中的文件选择对话框,用于用户去选择图片等文件 的过程中,遇到个问题,希望程序提供用户选择自己想要的图片作为Bird的图片. 但是当前开发环境是iOS模拟器,所 ...

随机推荐

  1. beego入门

    beego的官方仓库地址是 https://github.com/beego/beego 为什么要特别说明这个事情呢?因为我们引入的包地址,有可能是从官方fork的,特别是beego,有的教程上通过g ...

  2. ElasticSearch入门学习笔记

    ElasticSearch入门笔记 分页查询 from: 开始位置 size: 查多少条 GET /credit_enterprise_info/_search { "query" ...

  3. 关于在ItelliJ IDEA社区版找不到Spring Initializr

    搜了好几个版本都没找到,太难顶了... 打开「ItelliJ IDEA社区版」→「Configure」→「Plugins」→搜索框搜索「Spring Assistant」→「Install」 还要配置 ...

  4. centos7上安装使用docker环境

    系统环境准备: docker 运行在centos7上,要去系统为64位.系统内核版本为3.10以上 1.查看系统版本:cat/etc/redhat-release 2.查看系统内核版本:uname - ...

  5. OV5640数据的解码

    为了配合开发板的使用,笔者搞了一个OV5640的摄像头模组,OV5640具体的相关手册及资料网上已经很多,感兴趣的都可以自行去查找,基本大同小异.这里也不把OV5640初始化的代码贴出来,因为就是简单 ...

  6. 基于Axi4_lite的UART串口Verilog代码实现

    UART是通用异步收发传输器(Universal Asynchronous Receiver/Transmitter),通常称作UART,是一种异步收发传输器,是设备间进行异步通信的关键模块.UART ...

  7. rabbitMQ queue属性

    Map<String, Object> args = new HashMap<String, Object>(); args.put("x-message-ttl&q ...

  8. 动态规划-3-RNA的二级结构

    /*状态转移方程: OPT(i , j)= max(OPT(i , j − 1) , max( 1+OPT(i , t − 1)+OPT(t + 1, j − 1))), where the  max ...

  9. PowerShell学习笔记一_cmdlet、管道、如何入门

    PowerShell文件: .ps1 脚本文件 .psm1 模块文件 .psd1 模块描述文件 cmdlet(命令行) 组成: 动词-名词,例如: 1. Get-Service(获取所有服务),类似于 ...

  10. 数字图像处理之直方图处理——a cute dog huang

    关于图像处理的知识,确实很棒,在此感谢:https://blog.csdn.net/mary_0830/article/details/89003488 直方图处理概念灰度级范围为[0,L-1]的数字 ...