devxoul / UITextView-Placeholder

A missing placeholder for UITextView
MIT License
1.48k stars 259 forks source link

if set contentInset ,the placeholder location does't start like input text . #78

Open tanpengsccd opened 4 years ago

tanpengsccd commented 4 years ago

image code

text.contentInset = .init(top: 0, left: 20, bottom: 0, right: 20)
VincentSit commented 4 years ago

https://github.com/devxoul/UITextView-Placeholder/blob/5a133b7efc4e8dd9de91c9eada48270d90c83ef0/Sources/UITextView%2BPlaceholder.m#L201

The code above shows that you need to use textContainerInset instead of contentInset.

$0.textContainerInset = UIEdgeInsets(inset: 11)
$0.placeholder = ...