PlaceholderView.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: GPL-3.0-or-later
  4. */
  5. #import "PlaceholderView.h"
  6. #import "NCAppBranding.h"
  7. @interface PlaceholderView ()
  8. @property (strong, nonatomic) IBOutlet UIView *contentView;
  9. @end
  10. @implementation PlaceholderView
  11. - (instancetype)init
  12. {
  13. self = [super init];
  14. if (self) {
  15. [[NSBundle mainBundle] loadNibNamed:@"PlaceholderView" owner:self options:nil];
  16. [self addSubview:self.contentView];
  17. self.contentView.frame = self.bounds;
  18. }
  19. return self;
  20. }
  21. - (instancetype)initForTableViewStyle:(UITableViewStyle)style
  22. {
  23. self = [self init];
  24. if (self && (style == UITableViewStyleGrouped || style == UITableViewStyleInsetGrouped )) {
  25. self.contentView.backgroundColor = [UIColor systemGroupedBackgroundColor];
  26. self.placeholderView.backgroundColor = [UIColor systemGroupedBackgroundColor];
  27. }
  28. return self;
  29. }
  30. - (void)setImage:(UIImage *)image
  31. {
  32. UIImage *placeholderImage = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
  33. [self.placeholderImage setImage:placeholderImage];
  34. [self.placeholderImage setTintColor:[NCAppBranding placeholderColor]];
  35. }
  36. @end