iOS - 带字数和文案提示的输入框

2018-11-22  本文已影响42人  CDLOG

先上图:


image.png

1,使用方式

直接添加到要添加的view上就好了,很多东西都可以自定义,已经暴露在.h属性了,直接修改就好了。主要使用masonry布局。
例子

 [self.feedView setBackgroundColor:[UIColor clearColor]];
    
    self.C_textView = [[CL_TextView alloc]initWithFrame:self.feedView.bounds letfEdge:5 topEdgw:10 hintText:@"提示文案" maxLength:100];
    [self.C_textView setBackgroundColor:[UIColor orangeColor]];
    [self.C_textView.textView setFont:[UIFont systemFontOfSize:14]];
    [self.C_textView.hintLable setFont:[UIFont systemFontOfSize:14]];
    self.C_textView.hintLable.textColor =[UIColor grayColor];
    [self.C_textView.textLenthLable setFont:[UIFont systemFontOfSize:14]];
    self.C_textView.textLenthLable.textColor = [UIColor redColor];
    self.C_textView.radius = 4;
    [self.feedView addSubview:self.C_textView];

feedView 是要父控件,大小和输入框一样大就好了。设置一下内部控件的属性,主要是字体颜色大小之类的,添加到父控件就好了。

2,属性

@property (assign,nonatomic) CGFloat textView_leftEdge;
@property (assign,nonatomic) CGFloat textView_topEdge;
@property (strong,nonatomic) UITextView *textView;
@property (strong, nonatomic)  UILabel *hintLable;
@property (assign,nonatomic) NSInteger maxLength;
@property (strong, nonatomic)  UILabel *textLenthLable;
@property (assign,nonatomic) CGFloat radius;

github:https://github.com/CDLOG/CL_textView

上一篇 下一篇

猜你喜欢

热点阅读