Skip to content

Commit

Permalink
improve dark mode support
Browse files Browse the repository at this point in the history
  • Loading branch information
glaszig committed Apr 22, 2024
1 parent f3c5360 commit 72b1e4b
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion SZTextView/Sources/SZTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ - (id)initWithFrame:(CGRect)frame
}
#endif

+ (UIColor *)defaultPlaceholderColor
{
if (@available(iOS 13.0, *)) {
return [UIColor placeholderTextColor];
} else {
return [UIColor colorWithWhite:0.7f alpha:0.7f];
}
}

- (void)preparePlaceholder
{
NSAssert(!self._placeholderTextView, @"placeholder has been prepared already: %@", self._placeholderTextView);
Expand All @@ -68,7 +77,7 @@ - (void)preparePlaceholder
self._placeholderTextView = [[UITextView alloc] initWithFrame:frame];
self._placeholderTextView.opaque = NO;
self._placeholderTextView.backgroundColor = [UIColor clearColor];
self._placeholderTextView.textColor = [UIColor colorWithWhite:0.7f alpha:0.7f];
self._placeholderTextView.textColor = [self.class defaultPlaceholderColor];
self._placeholderTextView.textAlignment = self.textAlignment;
self._placeholderTextView.editable = NO;
self._placeholderTextView.scrollEnabled = NO;
Expand Down Expand Up @@ -132,6 +141,13 @@ - (void)preparePlaceholder
}
}

- (void)tintColorDidChange
{
[super tintColorDidChange];

self._placeholderTextView.textColor = [self.class defaultPlaceholderColor];
}

- (void)setPlaceholder:(NSString *)placeholderText
{
_placeholder = [placeholderText copy];
Expand Down

0 comments on commit 72b1e4b

Please sign in to comment.