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.placeholderTopDistance15;self.textView.placeholderLeftDistance20;self.textView.placeholderFont[UIFont systemFontOfSize:16];self.textView.font[UIFont systemFontOfSize:16];self.textView.placeholderColor[Color nonActivated];//上下左右的边距 使用textContainerInset设置top、left、botto, rightself.textView.textContainerInsetUIEdgeInsetsMake(15,20,5,5);//当光标在最后一行时始终显示低边距需使用contentInset设置bottom.self.textView.contentInsetUIEdgeInsetsMake(0,0,15,0);//防止在拼音打字时抖动self.textView.layoutManager.allowsNonContiguousLayoutNO;效果PlaceholderAndLimitTextView#importUIKit/UIKit.hNS_ASSUME_NONNULL_BEGINclassPlaceholderAndLimitTextView;protocolPlaceholderAndLimitTextViewDelegateNSObject-(void)placeholderAndLimitTextView:(PlaceholderAndLimitTextView*)textView returnCurrentValue:(NSString*)value;endinterfacePlaceholderAndLimitTextView:UIViewproperty(nonatomic,weak)idPlaceholderAndLimitTextViewDelegatedelegate;/** 占位文字 */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.placeholderTopDistance15;self.textView.placeholderLeftDistance20;self.textView.bgColor[Color backgroung];self.textView.contentFont[UIFont systemFontOfSize:16];self.textView.limitFont[UIFont systemFontOfSize:16];self.textView.limitColor[Color nonActivated];self.textView.limitCurrentCount0;self.textView.limitAllCount10;self.textView.delegateself;效果