想实现的效果:

//

//  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. 美国风投行业50年数据揭示的10条VC投资秘密法则

    美国风投行业50年数据揭示的10条VC投资秘密法则 来源:金融女王(微信号:FintechQ) 作者:Hatim Tyabji & Vijay Sathe 本文编译自以下外媒文章:  http ...

  2. Hive 内建操作符与函数开发——深入浅出学Hive

    第一部分:关系运算 Hive支持的关系运算符 •常见的关系运算符 •等值比较: = •不等值比较: <> •小于比较: < •小于等于比较: <= •大于比较: > •大 ...

  3. 二十四种设计模式:观察者模式(Observer Pattern)

    观察者模式(Observer Pattern) 介绍定义对象间的一种一对多的依赖关系,以便当一个对象的状态发生改变时,所有依赖于它的对象都得到通知并自动刷新. 示例有一个Message实体类,某些对象 ...

  4. BZOJ3157: 国王奇遇记 & 3516: 国王奇遇记加强版

    令\[S_i=\sum_{k=1}^n k^i m^k\]我们有\[\begin{eqnarray*}(m-1)S_i & = & mS_i - S_i \\& = & ...

  5. Cannot generate SSPI context

    请在参考如下文章前,重启服务器解决! 相信我 没错的! http://support.microsoft.com/kb/811889

  6. ray tracing/shadow,reflection, caustic

    看了一下午终于明白raytracing的算法了 不知道这次能记住多久 ssr我又完全不记得了 按照Henrik所说 理解raytracing的核心在于,它是从Eye到light反着走的 需要一个前序的 ...

  7. Mount CIFS

    mount -t cifs -o username="共享用户",password="密码" //ip/sharing_folder /mountpoint [ ...

  8. c语言指针详解 经典

    指针是C语言中广泛使用的一种数据类型. 运用指针编程是C语言最主要的风格之一.利用指针变量可以表示各种数据结构: 能很方便地使用数组和字符串: 并能象汇编语言一样处理内存地址,从而编出精练而高效的程序 ...

  9. 关于web项目中的图片上传、并在前端显示问题(tomcat中配置文件上传虚拟路径)

    一.数据库存储 直接把图片的二进制码存到数据库,可参考blog:http://blog.csdn.net/hope2jiang/article/details/590733 直接存图片在mysql上面 ...

  10. Android File类 根据官方文档理解

    File有四个构造函数        public File(File dir,String name)             参数为File和String,File制定构造的新的File对象的路径 ...