How to set left image icon in UITextView?
with padding because of which cannot overlap image and text on each other.
This is not UItextField,use "UITextView" instead of "UItextField" UItextField it gives inbuilt leftview and rightview which are absent in "UITextView"
class CustomTextView:UITextView{
/// A UIImage value that set LeftImage to the UITextView
@IBInspectable open var leftImage:UIImage? {
didSet {
if (leftImage != nil) {
self.leftImage(leftImage!)
}
}
}
fileprivate func leftImage(_ image: UIImage) {
let icn : UIImage = image
let imageView = UIImageView(image: icn)
imageView.frame = CGRect(x: 0, y: 2.0, width: icn.size.width + 20, height: icn.size.height)
imageView.contentMode = UIViewContentMode.center
}
I hope you understand what I should need.