如果我们想提交一些备注信息,会想到用textFiled和textView两种控件去实现

1.提醒文字是textFiled的特有属性,但是textFiled显示文本只有一行,不能实现我们输入较多文字的情况

2.textView可以自动适配多文字输入,但是没有提醒文字,这也不符合我们设计的需求

下面就有一种解决方法,话不多说,直接上代码

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #e44347 }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #ffffff; min-height: 28.0px }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #93c96a }
p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #c2349b }
p.p5 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #ffffff }
p.p6 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #00afca }
span.s1 { color: #d28f5a }
span.s2 { }
span.s3 { color: #c2349b }
span.s4 { color: #ffffff }
span.s5 { color: #00afca }
span.s6 { color: #93c96a }
span.s7 { color: #8b84cf }
span.s8 { color: #e44347 }

#import "YSCreateScheduleRemarkView.h"

#import "Masonry.h"

@interface YSCreateScheduleRemarkView ()

@end

@implementation YSCreateScheduleRemarkView

- (instancetype)initWithFrame:(CGRect)frame {

if (self = [super initWithFrame:frame]) {

[self initUI];

}

return self;

}

- (void)initUI {

self backgroundColor = [UIColor whiteColor];

_textView = [[UITextView alloc] init];

_textView.font = [UIFont systemFontOfSize:15];

[self addSubview:_textView];

[_textView mas_makeConstraints:^(MASConstraintMaker *make) {

make.top.mas_equalTo(self.mas_top);

make.left.mas_equalTo(self.mas_left).offset(10);

make.bottom.mas_equalTo(self.mas_bottom);

make.right.mas_equalTo(self.mas_right).offset(-10);

}];

}

- (void)setplaceholder:(NSString *)placeholder {

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

placeholderLabel.text = placeholder;

placeholderLabel.numberOfLines = 1;

placeholderLabel.textColor = [UIColor lightGrayColor];

[placeholderLabel sizeToFit];

placeholderLabel.font = _textView.font;

[_textView addSubview:placeholderLabel];

[_textView setValue:placeholderLabel forKey:@"_placeholderLabel"];

}

@end

p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #e44347 }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #ffffff; min-height: 28.0px }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #00afca }
p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #ffffff }
p.p5 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #c2349b }
p.p6 { margin: 0.0px 0.0px 0.0px 0.0px; font: 24.0px Menlo; color: #93c96a }
span.s1 { color: #d28f5a }
span.s2 { }
span.s3 { color: #c2349b }
span.s4 { color: #ffffff }
span.s5 { color: #93c96a }
span.s6 { color: #00afca }
span.s7 { color: #e44347 }
span.s8 { color: #8b84cf }
span.s9 { font: 24.0px "PingFang SC"; color: #e44347 }

#import "ViewController.h"

#import "YSCreateScheduleRemarkView.h"

@interface ViewController ()<UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate, UITextViewDelegate>

{

UITableView *table;

}

@property (nonatomic, strong) YSCreateScheduleRemarkView *createScheduleRemarkView;

@end

@implementation ViewController

- (void)viewDidLoad {

[super viewDidLoad];

self.view.backgroundColor = [UIColorwhiteColor];

table = [[UITableView alloc]initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStyleGrouped];

table.delegate = self;

table.dataSource = self;

[self.view addSubview:table];

[table registerClass:[UITableViewCell class] forCellReuseIdentifier:@"CreateScheduleCell"];

}

-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

return  4;

}

-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

{

return 0.01;

}

-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section

{

return 135;

}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {

_createScheduleRemarkView = [[YSCreateScheduleRemarkView alloc] init];

_createScheduleRemarkView.textView.delegate = self;

[_createScheduleRemarkView setplaceholder:@"备注"];

return _createScheduleRemarkView;

}

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CreateScheduleCell"];

cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CreateScheduleCell"];

cell.textLabel.text = @"12111";

return cell;

}

- (void)textViewDidBeginEditing:(UITextView *)textView {

[self showKeyboardManager:1]:

}

- (void)textViewDidEndEditing:(UITextView *)textView {

[self showKeyboardManager:0];

}

- (void)showKeyboardManager:(NSInteger)integer {

[UIView animateWithDuration:0.2f animations:^{

table.frame = CGRectMake(0, integer == 1 ? -44*4 : 0, 375, 667);

}];

}

textView的提醒文字的更多相关文章

  1. 解决TextView在显示文字的时候,一行还没显示满就跳到下一行

    转载请注明:转自 http://blog.csdn.NET/u011176685/article/details/48295185 一.问题描述: Android的TextView在显示文字的时候,如 ...

  2. 设置TextView显示的文字可以复制

    设置TextView显示的文字可以复制 效果图 在xml中设置 <TextView android:layout_width="wrap_content" android:l ...

  3. TextView 设置部分文字颜色及点击事件SpannableString

    设置TextView中一部分文字的颜色及点击事件. SpannableString gotoMsgListStr = new SpannableString("消息列表"); go ...

  4. Android的TextView在显示文字的时候,如果有段中文有英文,有中文,有中文标点符号,你会发现,当要换行的时候遇到中文标点, 这一行就会空出很多空格出来

    一.问题描述: Android的TextView在显示文字的时候,如果有段中文有英文,有中文,有中文标点符号,你会发现,当要换行的时候遇到中文标点, 这一行就会空出很多空格出来.原因是: 1) Tex ...

  5. Android中用TextView显示大量文字的方法

    最近学习Android中,试着实现一个简单的显示新闻Demo的时候,遇到了一个问题:一条新闻的内容文字很多,放在TextView上面超出屏幕了,怎么破? 查了一下资料,找到了两种方法实现: 1. 只用 ...

  6. Android TextView设置多彩文字

    在应用开发中时常会遇到需要在一段文字中插入几个不一样颜色文字的需求; 以前本人都是用多个TextView拼起来,不仅感觉很蠢,操作起来也蛮恶心; 直到接触到了SpannableStringBuilde ...

  7. android textview改变部分文字的颜色和string.xml中文字的替换(转)

    转   :http://blog.csdn.net/ljz2009y/article/details/23878669 一:TextView组件改变部分文字的颜色: TextView textView ...

  8. Android中TextView中的文字设置为不同颜色

    questionDesTextView=(TextView)findViewById(R.id.question_des); SpannableStringBuilder builder = new ...

  9. Android中动态更新TextView上的文字

    示例代码: 1.新线程,定时更新文字 class testThread extends Thread{ public void run() { Message message = new Messag ...

随机推荐

  1. swift学习笔记1——基础部分

    之前学习swift时的个人笔记,根据github:the-swift-programming-language-in-chinese学习.总结,将重要的内容提取,加以理解后整理为学习笔记,方便以后查询 ...

  2. 尝试解析js面试题(二)

    说明:一共有13题(原本14题,最后一道什么鬼,嫌弃不要了),覆盖面比较广,都属于比较烧脑的类型,各种神坑:不过对于夯实js理论基础帮助非常大:看看都能做对几题吧(

  3. 在tmux中的vi 上下左右键变为了ABCD等字符

    在本机上用vim编辑时,上下左右键没有问题,但是在tmux中确出现ABCD等字符. 原因是在tmux这个终端,默认做了字符转换,网上搜了很多答案,解决问题的设置是: set term=xterm

  4. 机器学习实战笔记(Python实现)-04-Logistic回归

    --------------------------------------------------------------------------------------- 本系列文章为<机器 ...

  5. ajax请求成功后打开新开窗口(window.open())被拦截的解决方法

    问题:今天在做项目时需要在ajax请求成功后打开一个新的窗口,此时遇到浏览拦截了新窗口的问题,尝试在ajax 回调函数中模拟执行 click 或者 submit 等用户行为(trigger('clic ...

  6. kmeans算法并行化的mpi程序

    用c语言写了kmeans算法的串行程序,再用mpi来写并行版的,貌似参照着串行版来写并行版,效果不是很赏心悦目~ 并行化思路: 使用主从模式.由一个节点充当主节点负责数据的划分与分配,其他节点完成本地 ...

  7. 最新官方WIN10系统32位,64位系统ghost版下载

    系统来自:系统妈 随着Windows 10Build 10074 Insider Preview版发布,有理由相信,Win10离最终RTM阶段已经不远了.看来稍早前传闻的合作伙伴透露微软将在7月底正式 ...

  8. python编码最佳实践之总结

    相信用python的同学不少,本人也一直对python情有独钟,毫无疑问python作为一门解释性动态语言没有那些编译型语言高效,但是python简洁.易读以及可扩展性等特性使得它大受青睐. 工作中很 ...

  9. Linux文件管理

    虚拟文件系统(VFS)概述: VFS位于文件系统.和访问文件的系统调用(API)之间,为系统调用访问文件系统提供统一的抽象接口. 不同文件系统连接成一个单一树形结构,分别挂载(自己挂载需要用mount ...

  10. 一步一步学FRDM-KE02Z(一):IAR调试平台搭建以及OpenSDA两种工作模式设置

    摘要:FRDM-KE02Z是飞思卡尔公司较为新的微控制器,学习和开发资料较少.从本篇开始会陆续介绍其相关的开发流程,并完成一个小型的工程项目.这是本系列博客的第一篇,主要介绍开发环境IAR for A ...