本文主要是介绍TextField.leftView,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
UITextField *testField = [[ UITextField alloc ] initWithFrame : CGRectMake ( 20 , 100 , 180 , 30 )];
testField. borderStyle = UITextBorderStyleRoundedRect ;
testField. borderStyle = UITextBorderStyleRoundedRect ;
//开启左边视图出现模式
testField. leftViewMode = UITextFieldViewModeAlways ;
testField. leftViewMode = UITextFieldViewModeAlways ;
UIImageView *imageView = [[ UIImageView alloc ] initWithFrame : CGRectMake ( 0 , 0 , 40 , 30 )];
UIImage *image = [ UIImage imageNamed : @"userName.png" ];
imageView. image = image;
//设置TextField左边视图
testField. leftView = imageView;
[ self . view addSubview :testField];
testField. leftView = imageView;
[ self . view addSubview :testField];
这篇关于TextField.leftView的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!