//設置文本框左邊的view UITextField *textField = [[UITextField alloc]init]; textField.frame = CGRectMake(10, 30, 300, 30); [self.view addSubview:textField]; textField.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 8, 0)]; //設置顯示模式爲永遠顯示(默認不顯示) textField.leftViewMode = UITextFieldViewModeAlways;