如何在UITextFields中为左视图图像添加X px填充?

时间:2016-05-22 05:27:59

标签: ios swift uiimageview uitextfield

我目前正在为我的文字字段加载图片,例如

fullNameField.delegate = self
    fullNameField.layer.cornerRadius = 15
    fullNameField.backgroundColor = UIColor.whiteColor()
    let fullNameImageView = UIImageView()
    let fullNameImage = UIImage(named: "FullName")
    fullNameImageView.frame = CGRect(x: 10, y: 10, width: 32, height: 32)
    fullNameImageView.image = fullNameImage
    fullNameField.addSubview(fullNameImageView)
    fullNameField.leftView = fullNameImageView
    fullNameField.leftViewMode = UITextFieldViewMode.Always

我可以加载所有内容,但我的图片视图框架不会向右和向下创建10像素的填充。

1 个答案:

答案 0 :(得分:0)

您是否尝试过使用边缘插图?

UIEdgeInsetsMake(x, x, x, x);