top accessory view
This commit is contained in:
parent
835eb3a43b
commit
f1b8a61e04
@ -38,6 +38,8 @@
|
||||
|
||||
#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
|
||||
- (void)buildInAdditionalViewsBeforeCenteredContent;
|
||||
// For subclassing. Should return all the views that will be in between labels and buttons. Override standardSpaceAroundUIObject to handle spacing.
|
||||
|
||||
@ -101,7 +101,13 @@
|
||||
// Removes the bottom view out of scroll if it is there.
|
||||
[self.viewOutOfScroll removeFromSuperview];
|
||||
[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.
|
||||
UIView *topView = [self useCustomViewInsteadOfLabels];
|
||||
self.topView = topView;
|
||||
@ -115,9 +121,8 @@
|
||||
}
|
||||
[self.contentView addSubview: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];
|
||||
self.topConstraintForTopView.active = YES;
|
||||
|
||||
[topAccessoryView.bottomAnchor constraintEqualToAnchor:topView.topAnchor constant:0].active = YES;
|
||||
|
||||
// Checks if we are using a different object than the bottom buttons.
|
||||
UIView *bottomView = [self useCustomViewInsteadOfButtons];
|
||||
self.customBottemView = (bottomView != nil);
|
||||
@ -266,7 +271,28 @@
|
||||
if (self.topLabelsView) {
|
||||
[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 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user