电子邮件图标和占位符文本都互相拥抱。
我想他们之间添加一些空间。
下面是我使用创建这些字段的代码。
// view for fields background
var view = UIView(frame: CGRectMake(35, 300, 300, 90));
view.backgroundColor = UIColor.whiteColor();
view.layer.cornerRadius = 5.0
// email text field
var email = UITextField(frame: CGRectMake(0, 0, 300, 50));
email.backgroundColor = UIColor.whiteColor();
var emailIcon = UIImageView();
var emailIconImage = UIImage(named: "email_icon.png");
emailIcon.image = emailIconImage;
email.leftView = emailIcon;
email.leftViewMode = UITextFieldViewMode.Always
email.layer.cornerRadius=5.0;
email.attributedPlaceholder = NSAttributedString(string:"E-mail",
attributes:[NSForegroundColorAttributeName: UIColor.grayColor()])
emailIcon.frame = CGRect(x: 30, y: 15, width: 30, height: 20)
view.addSubview(emailIcon)
谢谢!