HeaderWithButton.m 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /**
  2. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  3. * SPDX-License-Identifier: GPL-3.0-or-later
  4. */
  5. #import "HeaderWithButton.h"
  6. @interface HeaderWithButton ()
  7. @property (strong, nonatomic) IBOutlet UIView *contentView;
  8. @end
  9. @implementation HeaderWithButton
  10. - (instancetype)init
  11. {
  12. self = [super init];
  13. if (self) {
  14. [[NSBundle mainBundle] loadNibNamed:@"HeaderWithButton" owner:self options:nil];
  15. _label.textColor = [UIColor secondaryLabelColor];
  16. [self addSubview:self.contentView];
  17. if ([UIView userInterfaceLayoutDirectionForSemanticContentAttribute:_label.semanticContentAttribute] == UIUserInterfaceLayoutDirectionRightToLeft) {
  18. _label.textAlignment = NSTextAlignmentRight;
  19. _button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
  20. } else {
  21. _label.textAlignment = NSTextAlignmentLeft;
  22. _button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
  23. }
  24. self.contentView.frame = self.bounds;
  25. }
  26. return self;
  27. }
  28. @end