devxoul / UITextView-Placeholder

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

Fixes case when font is different from attributed font. #44

Open popwarfour opened 6 years ago

popwarfour commented 6 years ago

Bug There is a bug where a font attributed is ignored (when using attributedPlaceholder). The UITextView's font is used instead.

Fix Checks to see if there is font set on the attributed placeholder. If so we use that. If not we fall back and use the UITextView's font instead.

popwarfour commented 6 years ago

your unit tests didn't catch it because you needed to check against the placeholderLabel.font instead. I can update those also if you'd like?

devxoul commented 6 years ago

Hmm, how about just not updating the font if there is attributedPlaceholder? For example:

 if (self.needsUpdateFont) {
-    self.placeholderLabel.font = self.font;
+    if (self.attributedPlaceholer != nil) {
+        self.placeholderLabel.font = self.font;
+    }
     self.needsUpdateFont = NO;
 }