var leftImageView = UIImageView()
leftImageView.image = leftImage
textField.leftView = leftImageView
textField.leftViewMode = UITextFieldViewMode.Always
leftImageView.frame = CGRectMake(15, 10, 15, 20)
textField.addSubview(leftImageView)
我發現像從上述代碼
textField.leftView = leftImageView
它給圖標刪除此代碼溶液添加圖標中的UITextField對齊正確,但每當開始編輯像這樣的圖標上的文本字段文本
我想這樣
在swift 3.0中試試這個很酷的庫https://github.com/Sahilberi/ImageTextField – Sahil