UIView *commentView = [[UIView alloc]initWithFrame:CGRectMake(0, Kheight-35, Kwidth, 35)];
commentView.backgroundColor =[UIColor yellowColor];
[self.view addSubview:commentView];
UITextField *commentText = [[UITextField alloc]initWithFrame:CGRectMake(10, 2.5, 194, 30)];
commentText.font = JhFontsize(12);
commentText.textColor =BaseBlackTextColor;
commentText.backgroundColor = BaselineColor;
commentText.placeholder = @"写评论...";
commentText.layer.cornerRadius = 15.0;
[commentView addSubview:commentText];
//文本框左视图
UIView *leftView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 37, 30)];
leftView.backgroundColor = [UIColor clearColor];
//添加图片
UIImageView *headView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 5, 20, 20)];
headView.image = [UIImage imageNamed:@"ic_xiepinglun"];
[leftView addSubview:headView];
commentText.leftView = leftView;
commentText.leftViewMode = UITextFieldViewModeAlways;
//监听开始编辑状态
[TextField addTarget:self action:@selector(didediting) forControlEvents:UIControlEventEditingDidBegin];// 可在自定义selector处
//监听编辑完成的状态
[TextField addTarget:self action:@selector(endediting) forControlEvents:UIControlEventEditingDidEnd];// 可在自定义selector处
-(void)didediting
{
NSLog(@"开始编辑");
}
-(void)endediting
{
NSLog(@"停止编辑");
}