当前位置: 首页 > news >正文

OC Extension TextView

一直觉得自己写的不是技术,而是情怀,一个个的教程是自己这一路走来的痕迹。靠专业技能的成功是最具可复制性的,希望我的这条路能让你们少走弯路,希望我能帮你们抹去知识的蒙尘,希望我能帮你们理清知识的脉络,希望未来技术之巅上有你们也有我。

OC 项目底层框架(万能)

2021.2.16 FHXPlaceholderTextView下载链接

2021.5.26 OC Extension FHXPlaceholderTextView下载链接

说明系统自带的UITextView是没有输入提示的UITextField才有,所以自己写了一个FHXPlaceholderTextView。

PlaceholderAndLimitTextView这个右下角还带有限制文字输入的提示(下面有效果图)

先讲 FHXPlaceholderTextView

/** 占位文字 */@property(nonatomic,copy)NSString*placeholder;/** 占位文字的颜色 */@property(nonatomic,strong)UIColor*placeholderColor;/** 占位文字的大小 */@property(nonatomic,strong)UIFont*placeholderFont;/** 占位文字的左边距离 */@property(nonatomic,assign)CGFloat placeholderLeftDistance;/** 占位文字的右边距离 */@property(nonatomic,assign)CGFloat placeholderTopDistance;

使用

self.textView=[FHXPlaceholderTextView new];self.textView.addTo(self).bgColor([Color randomColor]);self.textView.placeholder=@"写下您宝贵的建议,我们将尽快处理";self.textView.placeholderTopDistance=15;self.textView.placeholderLeftDistance=20;self.textView.placeholderFont=[UIFont systemFontOfSize:16];self.textView.font=[UIFont systemFontOfSize:16];self.textView.placeholderColor=[Color nonActivated];//上下左右的边距 使用textContainerInset设置top、left、botto, rightself.textView.textContainerInset=UIEdgeInsetsMake(15,20,5,5);//当光标在最后一行时,始终显示低边距,需使用contentInset设置bottom.self.textView.contentInset=UIEdgeInsetsMake(0,0,15,0);//防止在拼音打字时抖动self.textView.layoutManager.allowsNonContiguousLayout=NO;

效果


PlaceholderAndLimitTextView

#import<UIKit/UIKit.h>NS_ASSUME_NONNULL_BEGIN@classPlaceholderAndLimitTextView;@protocolPlaceholderAndLimitTextViewDelegate<NSObject>-(void)placeholderAndLimitTextView:(PlaceholderAndLimitTextView*)textView returnCurrentValue:(NSString*)value;@end@interfacePlaceholderAndLimitTextView:UIView@property(nonatomic,weak)id<PlaceholderAndLimitTextViewDelegate>delegate;/** 占位文字 */@property(nonatomic,copy)NSString*placeholder;/** 占位文字的颜色 */@property(nonatomic,strong)UIColor*placeholderColor;/** 占位文字的大小 */@property(nonatomic,strong)UIFont*placeholderFont;/** 占位文字的左边距离 */@property(nonatomic,assign)CGFloat placeholderLeftDistance;/** 占位文字的右边距离 */@property(nonatomic,assign)CGFloat placeholderTopDistance;/** textView背景颜色 */@property(nonatomic,strong)UIColor*bgColor;/** textView内容文字大小 */@property(nonatomic,strong)UIFont*contentFont;/** 限制文字大小 */@property(nonatomic,strong)UIFont*limitFont;/** 限制文字颜色 */@property(nonatomic,strong)UIColor*limitColor;/** 限制文字总数 */@property(nonatomic,assign)NSInteger limitAllCount;/** 当前文字个数 */@property(nonatomic,assign)NSInteger limitCurrentCount;@endNS_ASSUME_NONNULL_END

使用

self.textView.addTo(self.view).borderRadius(8).xywh(rectTextView.origin.x,rectTextView.origin.y,Phone_Width-30,200);self.textView.placeholder=@"写下您宝贵的建议,我们将尽快处理";self.textView.placeholderColor=[Color nonActivated];self.textView.placeholderFont=[UIFont systemFontOfSize:16];self.textView.placeholderTopDistance=15;self.textView.placeholderLeftDistance=20;self.textView.bgColor=[Color backgroung];self.textView.contentFont=[UIFont systemFontOfSize:16];self.textView.limitFont=[UIFont systemFontOfSize:16];self.textView.limitColor=[Color nonActivated];self.textView.limitCurrentCount=0;self.textView.limitAllCount=10;self.textView.delegate=self;

效果

http://www.jsqmd.com/news/620559/

相关文章:

  • 鸿蒙 PC 的机会在哪里?
  • 【2024最严合规迁移标准】:金融级遗留系统AI重构必须满足的11项审计红线(附自查表PDF)
  • AI Agent 跑完任务怎么通知你?我写了个微信推送服务闭
  • FanControl深度解析:从硬件控制原理到高级风扇管理实战指南
  • 零成本!Ollama本地部署国产大模型全指南(支持Kimi-K2.5/GLM-5/Qwen,新手秒上手)
  • 如何用CuteTranslation解决Linux屏幕翻译难题:完整技术指南
  • VirtualLab Fusion界面导航:从菜单栏到工具箱的全面解析
  • Golang切片append怎么用_Golang切片扩容机制教程【推荐】
  • ShutUp10++ vs 其他隐私工具:实测对比哪款更适合你的Windows系统优化需求
  • 深入rust-cross:理解Rust跨编译的术语与架构原理完整指南
  • 物联网浏览器(IoTBrowser)-js开发人脸识别部
  • 2026届毕业生推荐的六大AI写作方案推荐
  • akbdjehjdjdbfjdnf
  • Leather Dress Collection惊艳效果:Leather_TankTop_Pants皮背心+工装短裤街头风作品
  • 三大技术突破:重新定义Android设备标识的完整解决方案
  • RK3588平台RKNN-Toolkit2模型量化与性能优化实战指南
  • 如何用图形界面轻松下载M3U8视频:N_m3u8DL-CLI-SimpleG完全指南
  • [S32K3实战指南] 一站式搞定NXP S32K3开发环境:从RTD集成到IDE配置
  • 告别华而不实:H3C TX1801 Plus刷OpenWRT后,IPv6和插件功能实测
  • 如何利用SQL查询快速统计分类数据_配合GROUP BY使用
  • OC Control PPNumberButton
  • 构建具备批判性思维的AI Agent
  • 保姆级教程:为阿里SenseVoice模型添加字幕时间轴(Python+FunASR)
  • MiniCPM-V 4.5本地部署指南:从环境配置到图片视频推理全流程(附常见错误排查)
  • 手把手教你用ATC工具把ONNX模型转成昇腾310P3能跑的.om文件(附完整命令)
  • 深度图聚类:从学习范式到应用场景的演进与剖析
  • Chamber多后端支持:SSM、Secrets Manager、S3全攻略
  • LinkedIn 2026内容算法报告:这3类内容触达率暴涨47%,你的团队还在发错的那种 - SocialEcho社媒管理
  • SP3485芯片应用避坑指南:手把手调试RS485半双工通信
  • NVIDIA FoundationStereo实战:如何用零样本技术搞定复杂场景的立体匹配?