top accessory view
This commit is contained in:
parent
835eb3a43b
commit
f1b8a61e04
@ -38,6 +38,8 @@
|
|||||||
|
|
||||||
#pragma mark - Subclass
|
#pragma mark - Subclass
|
||||||
|
|
||||||
|
- (nullable NSArray *)topAccessoryViews;
|
||||||
|
|
||||||
// Allow you to add any additional ui before buildViewsBetweenLabelsAndButtons gets called. Can use this to set the topBetweenEdgeView or bottomBetweenEdgeView
|
// Allow you to add any additional ui before buildViewsBetweenLabelsAndButtons gets called. Can use this to set the topBetweenEdgeView or bottomBetweenEdgeView
|
||||||
- (void)buildInAdditionalViewsBeforeCenteredContent;
|
- (void)buildInAdditionalViewsBeforeCenteredContent;
|
||||||
// For subclassing. Should return all the views that will be in between labels and buttons. Override standardSpaceAroundUIObject to handle spacing.
|
// For subclassing. Should return all the views that will be in between labels and buttons. Override standardSpaceAroundUIObject to handle spacing.
|
||||||
|
|||||||
@ -102,6 +102,12 @@
|
|||||||
[self.viewOutOfScroll removeFromSuperview];
|
[self.viewOutOfScroll removeFromSuperview];
|
||||||
[StackableViewController removeUIViews:[self.contentView subviews]];
|
[StackableViewController removeUIViews:[self.contentView subviews]];
|
||||||
|
|
||||||
|
UIView *topAccessoryView = [self setUpTopAccessoryView];
|
||||||
|
[self.contentView addSubview:topAccessoryView];
|
||||||
|
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[topAccessoryView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topAccessoryView)]];
|
||||||
|
self.topConstraintForTopView = [NSLayoutConstraint constraintWithItem:topAccessoryView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
|
||||||
|
self.topConstraintForTopView.active = YES;
|
||||||
|
|
||||||
// Checks if we are using a different object than top labels.
|
// Checks if we are using a different object than top labels.
|
||||||
UIView *topView = [self useCustomViewInsteadOfLabels];
|
UIView *topView = [self useCustomViewInsteadOfLabels];
|
||||||
self.topView = topView;
|
self.topView = topView;
|
||||||
@ -115,8 +121,7 @@
|
|||||||
}
|
}
|
||||||
[self.contentView addSubview:topView];
|
[self.contentView addSubview:topView];
|
||||||
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[topView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topView)]];
|
[NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[topView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topView)]];
|
||||||
self.topConstraintForTopView = [NSLayoutConstraint constraintWithItem:topView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0];
|
[topAccessoryView.bottomAnchor constraintEqualToAnchor:topView.topAnchor constant:0].active = YES;
|
||||||
self.topConstraintForTopView.active = YES;
|
|
||||||
|
|
||||||
// Checks if we are using a different object than the bottom buttons.
|
// Checks if we are using a different object than the bottom buttons.
|
||||||
UIView *bottomView = [self useCustomViewInsteadOfButtons];
|
UIView *bottomView = [self useCustomViewInsteadOfButtons];
|
||||||
@ -266,7 +271,28 @@
|
|||||||
if (self.topLabelsView) {
|
if (self.topLabelsView) {
|
||||||
[self.topLabelsView setHeadlineString:[[self mapForTopLabels] stringForKey:KeyTitle] messageString:[[self mapForTopLabels] stringForKey:KeyMessage]];
|
[self.topLabelsView setHeadlineString:[[self mapForTopLabels] stringForKey:KeyTitle] messageString:[[self mapForTopLabels] stringForKey:KeyMessage]];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (nullable NSArray *)topAccessoryViews {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (UIView *)setUpTopAccessoryView {
|
||||||
|
UIView *headerAccessoryView = [[UIView alloc] initWithFrame:CGRectZero];
|
||||||
|
headerAccessoryView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||||
|
NSArray *accessoryViews = [self topAccessoryViews];
|
||||||
|
if (accessoryViews.count > 0) {
|
||||||
|
__block typeof(self) weakSelf = self;
|
||||||
|
[StackableViewController populateView:headerAccessoryView withUIArray:accessoryViews withSpacingBlock:^UIEdgeInsets(id _Nullable object) {
|
||||||
|
UIEdgeInsets edgeInsets = [weakSelf spaceAroundUIObject:object];
|
||||||
|
edgeInsets.left = 0;
|
||||||
|
edgeInsets.right = 0;
|
||||||
|
return edgeInsets;
|
||||||
|
}];
|
||||||
|
} else {
|
||||||
|
[NSLayoutConstraint constraintPinView:headerAccessoryView heightConstraint:YES heightConstant:0 widthConstraint:NO widthConstant:0];
|
||||||
|
}
|
||||||
|
return headerAccessoryView;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateViewConstraints {
|
- (void)updateViewConstraints {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user