想实现的效果:

//

//  LHQsuggestionViewCtrl.m

//  A13 - 设置

//

//  Created by vic fan on 16/6/23.

//  Copyright © 2016年 李洪强. All rights reserved.

//

#import "LHQsuggestionViewCtrl.h"

#define ScreenWidth [UIScreen mainScreen].bounds.size.width

#define ScreenHeight [UIScreen mainScreen].bounds.size.height

@interface LHQsuggestionViewCtrl ()<UITextViewDelegate>

@property(nonatomic,strong)UILabel *label1;

@property(nonatomic,weak)UITextView *textView1;

@end

@implementation LHQsuggestionViewCtrl

- (void)viewDidLoad{

[super viewDidLoad];

self.title = @"意见反馈";

//  self.view.backgroundColor = [UIColor colorWithRed:239/255.0 green:239/255.0 blue:244/255.0 alpha:1];

self.view.backgroundColor = [UIColor whiteColor];

//----------------------设置带place

UITextView *textView = [[UITextView alloc] init];

self.textView1 = textView;

self.textView1.font = [UIFont systemFontOfSize:14];

self.textView1.frame =CGRectMake(20, 150,[UIScreen mainScreen].bounds.size.width -40, 200);

self.textView1.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;

self.textView1.layer.borderColor = [UIColor colorWithRed:239/255.0 green:239/255.0 blue:244/255.0 alpha:1].CGColor;

self.textView1.layer.masksToBounds = YES;

self.textView1.layer.borderWidth = 1;

self.textView1.backgroundColor = [UIColor whiteColor];

//    self.modalPresentationCapturesStatusBarAppearance = NO;

//    self.edgesForExtendedLayout = UIRectEdgeNone;

//    self.extendedLayoutIncludesOpaqueBars = NO;

[self.view addSubview:self.textView1];

self.textView1.hidden = NO;

self.textView1.delegate = self;

self.automaticallyAdjustsScrollViewInsets =NO;

//其次在UITextView上面覆盖个UILable,UILable设置为全局变量。

UILabel *label1 = [[UILabel alloc]init];

self.label1 = label1;

self.label1.frame =CGRectMake(3, 3, [UIScreen mainScreen].bounds.size.width -50, 20);

self.label1.text = @"请输入您的宝贵意见,建议,我们将不断完善";

self.label1.enabled = NO;//lable必须设置为不可用

self.label1.backgroundColor = [UIColor clearColor];

self.label1.font = [UIFont systemFontOfSize:14];

[self.textView1 addSubview:self.label1];

//----------------------------------------------------------

UILabel *topLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 80, 150, 30)];

topLabel.text = @"您的宝贵建议:";

[self.view addSubview:topLabel];

}

//  实现UITextView的代理

-(void)textViewDidChange:(UITextView *)textView

{

self.textView1.text = textView.text;

if (textView.text.length == 0) {

self.label1.text = @"请输入您的宝贵意见,建议,我们将不断完善";

}else{

self.label1.text = @"";

}

}

- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{

self.label1.text = @"";

//  [self.label1 removeFromSuperview];

return YES;

}

- (BOOL)textViewShouldEndEditing:(UITextView *)textView{

self.label1.text = @"请输入您的宝贵意见,建议,我们将不断完善";

return YES;

}

- (void)btnClick{

NSLog(@"点击了提示");

}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

[UIView animateWithDuration:0.8 animations:^{

[self.view endEditing:YES];

}];

}

@end

自定义textView的placeholder和边框的更多相关文章

  1. ios开发之自定义textView

    自定义textView,从理论上讲很简单,根据需求自定义,比如我在开发中的需求就是现实一个字数的限制以及根据输入的文字改变提示剩余字数,那么开始我的基本思路就是自定义一个View,而里面包含一个子控件 ...

  2. 自定义TextView 调用ttf格式字体

    自定义TextView 调用ttf格式字体 1.<strong>将ttf格式文件存放在assets/fonts/下</strong> 注:PC系统字体存放在C:\Windows ...

  3. [原创]Android秒杀倒计时自定义TextView

    自定义TextView控件TimeTextView代码: import android.content.Context; import android.content.res.TypedArray; ...

  4. 安卓自定义TextView实现自动滚动

    xml文件代码 <com.mobile.APITest.ScrollEditText android:id="@+id/statusEditText" android:lay ...

  5. Android开发学习笔记-自定义TextView属性模版

    如果项目中有很多个控件使用的是同一种样式,则为了方便,可以将样式设置到系统中去,这样使用的时候会方便很多. 下面是自定义样式模版的方法. 1.在style.xml文件中添加自己要设置的样式内容 < ...

  6. 自定义TextView带有各类.ttf字体的TextView

    最近项目遇到了将普通文字转化为带有字体样式的文字,这里就涉及到了.ttf文件,我上网百度了不少资料最终终于实现了,现在想想其实并不复杂 1,你需要下载一种.ttf字体文件,你可以从网上找到一种字体的. ...

  7. Android源码分析(十二)-----Android源码中如何自定义TextView实现滚动效果

    一:如何自定义TextView实现滚动效果 继承TextView基类 重写构造方法 修改isFocused()方法,获取焦点. /* * Copyright (C) 2015 The Android ...

  8. 练习,自定义TextView(1.1)

    重新自定义TextView是非常有趣的事情,跟着Android4高级编程,通过自定义TextView,来敲一下代码: 这个是那么的简单,自定义TextView,新建CustomTextView继承Te ...

  9. 自定义textview

    #import <UIKit/UIKit.h> @class FSTextView; typedef void(^FSTextViewHandler)(FSTextView *textVi ...

随机推荐

  1. python部署工具fabric

    两台机器:10.1.6.186.10.1.6.159.fabric部署在10.1.6.186上面 1  执行和1相同的任务,不过排除掉10.1.6.159这台机器 1 #!/usr/bin/pytho ...

  2. JavaWeb对RSA的使用

    由于公司的网站页面的表单提交是明文的post,虽说是https的页面,但还是有点隐患(https会不会被黑?反正明文逼格是差了点你得承认啊),所以上头吩咐我弄个RSA加密,客户端JS加密,然后服务器J ...

  3. matplotlib绘制常用统计图

    常见统计图:单条折线图.多条折线图.直方图.柱状图.饼状图 #!/usr/bin/python # -*- coding: utf-8 -*- import numpy as np import ma ...

  4. Sublimetext 3 经常使用插件

    今天配了一下开发工具,事实上主要是想配置svn插件,可是后来查了下,发现sublimet的插件库还是蛮丰富的.顺手安了一些别的插件进去. 1,Svn插件安装的一些问题 首先ctrl+shift+p,打 ...

  5. cocos2d-x 托付模式的巧妙运用——附源代码(二)

    转载请注明出处:http://blog.csdn.net/hust_superman/article/details/38292265,谢谢. 继上一篇将了托付类的详细实现后.这篇来将一下怎样在游戏中 ...

  6. 深入分析JavaWeb Item24 -- jsp2.X自己定义标签开发进阶

    一.简单标签(SimpleTag) 由于传统标签使用三个标签接口来完毕不同的功能,显得过于繁琐.不利于标签技术的推广, SUN公司为减少标签技术的学习难度,在JSP 2.0中定义了一个更为简单.便于编 ...

  7. Java调用本地接口:java.lang.UnsatisfiedLinkError

    Java调用本地接口:java.lang.UnsatisfiedLinkError 我的问题不在这篇文章描述中, 而是因为jni原来是c实现, 现在切换到cpp了, 需要在对应的cpp文件中加入ext ...

  8. 多媒体封装格式详解---MP4

    MP4文件格式详解——结构概述 http://blog.csdn.net/pirateleo/article/details/7061452 一.基本概念 1. 文件,由许多Box和FullBox组成 ...

  9. js中,{}初始化数据类型object;for in 的用法;delete的用法

    var choices = {}; //此数据表示的是:object{} for(var i=0;i<10;i++){ choices[i+1] = [data[i].testPlan,test ...

  10. iOS中 最新微信支付/最全的微信支付教程具体解释 韩俊强的博客

    亲们, 首先让我们来看一下微信支付的流程吧. 1. 注冊微信开放平台,创建应用获取appid,appSecret,申请支付功能,申请成功之后会返回一些參数. 2. 下载微信支付sdk 3. clien ...