Position of rightView UITextField

前端 未结 3 1097
失恋的感觉
失恋的感觉 2021-01-04 18:21

Is there a way to adjust the position of a rightView on UITextField? I tried setting the frame on the view (set as rightView) but it didn\'t change anything.

I\'d li

3条回答
  •  梦毁少年i
    2021-01-04 19:13

    Right Padding you can use as

    let imageview = UIImageView(image: UIImage(named: "image name"))
    imageview.contentMode = .center
    
    let rightPadding: CGFloat = 14 //--- change right padding 
    imageview.frame = CGRect(x: 0, y: 0, width: imageview.frame.size.width + rightPadding , height:imageview.frame.size.height)
    
    textField.rightViewMode = .always
    textFieldd.rightView = imageview
    

提交回复
热议问题