| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- //
- // UASInputView.m
- // shiku_im
- //
- // Created by liyangyang-pc on 2018/7/9.
- //
- #import "UASInputTextView.h"
- #import "BRPlaceholderTextView.h"
- @interface UASInputTextView ()<UITextViewDelegate>
- {
- UIView *bgview;
- UILabel *nameLabel;
- BRPlaceholderTextView *view;
- }
- @end
- @implementation UASInputTextView
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self) {
-
- [self setView];
-
-
-
- }
- return self;
- }
- - (void)setView{
-
-
- self.backgroundColor = Color(0, 0, 0, 0.5);
-
-
- bgview =[[UIView alloc] initWithFrame:CGRectMake(30, 200, SCREEN_WIDTH -60, 161) ];
-
- bgview.backgroundColor = BGKJ_COLOR;
-
- [self addSubview:bgview];
-
- nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, bgview.frame.size.width, 20)];
- nameLabel.font = FONT_SIZE(18);
-
-
- nameLabel.textAlignment = NSTextAlignmentCenter;
-
- nameLabel.font = FONT_SIZE(16);
- nameLabel.text = @"备注";
-
- [bgview addSubview:nameLabel];
-
- view=[[BRPlaceholderTextView alloc]initWithFrame:CGRectMake(25,35,bgview.frame.size.width-50,75)];
- view.placeholder=@"请输入";
- view.font=FONT_SIZE(16);
-
- view.backgroundColor = BGKJ_COLOR;
-
- view.layer.borderColor=[UIColor lightGrayColor].CGColor;
- view.returnKeyType = UIReturnKeyDone;
- view.delegate = self;
-
-
- [view addMaxTextLengthWithMaxLength:1000 andEvent:^(BRPlaceholderTextView *text) {
-
-
- }];
-
-
-
-
- [view addTextViewBeginEvent:^(BRPlaceholderTextView *text) {
-
- }];
-
- [view addTextViewEndEvent:^(BRPlaceholderTextView *text) {
-
- }];
-
- [bgview addSubview:view];
-
- UIButton * _SkipThisStepbtn = [UIButton buttonWithType:UIButtonTypeCustom];
-
- _SkipThisStepbtn.frame = CGRectMake((bgview.frame.size.width/3-61)*2+94, 116, 94, 35);
-
-
-
- [_SkipThisStepbtn setTitle:Localized(@"UU_custom_sure") forState:UIControlStateNormal];
- [_SkipThisStepbtn setTitleColor:Color(51, 162, 238, 1.0) forState:UIControlStateNormal];
- [_SkipThisStepbtn setBackgroundColor:BGKJ_COLOR forState:UIControlStateNormal];
- [_SkipThisStepbtn setBackgroundColor:Color(51, 162, 238, 1.0) forState:UIControlStateHighlighted];
- [_SkipThisStepbtn setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
-
-
-
- [_SkipThisStepbtn addTarget:self action:@selector(butAction) forControlEvents:UIControlEventTouchUpInside];
- _SkipThisStepbtn.layer.cornerRadius = 5.0f;
- _SkipThisStepbtn.layer.borderColor = Color(51, 162, 238, 1.0).CGColor;
- _SkipThisStepbtn.layer.borderWidth = 0.8f;
- _SkipThisStepbtn.layer.masksToBounds= YES;
-
- [bgview addSubview:_SkipThisStepbtn];
-
- UIButton *SkipThisStepbtn1 = [UIButton buttonWithType:UIButtonTypeCustom];
-
- SkipThisStepbtn1.frame =CGRectMake(bgview.frame.size.width/3 -61 ,116, 94, 35);
- [SkipThisStepbtn1 addTarget:self action:@selector(butAction1) forControlEvents:UIControlEventTouchUpInside];
- [SkipThisStepbtn1 setTitle:Localized(@"UU_custom_cancle") forState:UIControlStateNormal];
-
- [SkipThisStepbtn1 setTitleColor:Color(51, 162, 238, 1.0) forState:UIControlStateNormal];
-
- [SkipThisStepbtn1 setBackgroundColor:BGKJ_COLOR forState:UIControlStateNormal];
- [SkipThisStepbtn1 setBackgroundColor:Color(51, 162, 238, 1.0) forState:UIControlStateHighlighted];
- [SkipThisStepbtn1 setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
- [bgview addSubview:SkipThisStepbtn1];
-
-
- SkipThisStepbtn1.layer.cornerRadius = 5.0f;
- SkipThisStepbtn1.layer.borderColor = Color(51, 162, 238, 1.0).CGColor;
- SkipThisStepbtn1.layer.borderWidth = 0.8f;
- SkipThisStepbtn1.layer.masksToBounds = YES;
-
- bgview.layer.cornerRadius = 5.0;
- bgview.layer.masksToBounds = YES;
-
-
- }
- -(void)butAction1
- {
- self.blcok(@"");
-
- [self removeFromSuperview];
-
- }
- - (void)butAction{
- if (view.text != 0) {
- self.blcok(view.text);
-
- }
- [self removeFromSuperview];
-
-
-
- }
- -(void)setTypeStr:(NSString *)typeStr
- {
- _typeStr = typeStr;
- view.text = typeStr;
-
- }
- - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
- if ([text isEqualToString:@"\n"]){ //判断输入的字是否是回车,即按下return
- //在这里做你响应return键的代码
- [view resignFirstResponder];
- return NO; //这里返回NO,就代表return键值失效,即页面上按下return,不会出现换行,如果为yes,则输入页面会换行
- }
-
-
- return YES;
- }
- @end
|