diff --git a/VGParallaxHeader/UIScrollView+VGParallaxHeader.h b/VGParallaxHeader/UIScrollView+VGParallaxHeader.h index cb17277..eda59b6 100755 --- a/VGParallaxHeader/UIScrollView+VGParallaxHeader.h +++ b/VGParallaxHeader/UIScrollView+VGParallaxHeader.h @@ -12,6 +12,7 @@ typedef NS_ENUM(NSInteger, VGParallaxHeaderMode) { VGParallaxHeaderModeFill, VGParallaxHeaderModeTop, VGParallaxHeaderModeTopFill, + VGParallaxHeaderModeBottomFill, }; typedef NS_ENUM(NSInteger, VGParallaxHeaderStickyViewPosition) { diff --git a/VGParallaxHeader/UIScrollView+VGParallaxHeader.m b/VGParallaxHeader/UIScrollView+VGParallaxHeader.m index 1cae7c6..4d132c2 100755 --- a/VGParallaxHeader/UIScrollView+VGParallaxHeader.m +++ b/VGParallaxHeader/UIScrollView+VGParallaxHeader.m @@ -256,6 +256,9 @@ - (void)setupContentViewMode case VGParallaxHeaderModeTopFill: [self addContentViewModeTopFillConstraints]; break; + case VGParallaxHeaderModeBottomFill: + [self addContentViewModeBottomFillConstraints]; + break; case VGParallaxHeaderModeCenter: default: [self addContentViewModeCenterConstraints]; @@ -364,6 +367,30 @@ - (void)addContentViewModeTopFillConstraints self.insetAwareSizeConstraint.priority = UILayoutPriorityDefaultHigh; } + +- (void)addContentViewModeBottomFillConstraints +{ + [self.contentView autoPinEdgeToSuperviewEdge:ALEdgeLeft + withInset:0]; + [self.contentView autoPinEdgeToSuperviewEdge:ALEdgeRight + withInset:0]; + + NSArray *array = [self.contentView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(self.originalTopInset, 0, 0, 0) + excludingEdge:ALEdgeTop]; + self.insetAwarePositionConstraint = [array firstObject]; + + NSLayoutConstraint *constraint = [self.contentView autoSetDimension:ALDimensionHeight + toSize:self.originalHeight + relation:NSLayoutRelationGreaterThanOrEqual]; + constraint.priority = UILayoutPriorityRequired; + + self.insetAwareSizeConstraint = [self.contentView autoMatchDimension:ALDimensionHeight + toDimension:ALDimensionHeight + ofView:self.containerView + withOffset:-self.originalTopInset]; + self.insetAwareSizeConstraint.priority = UILayoutPriorityDefaultHigh; +} + - (void)addContentViewModeCenterConstraints { [self.contentView autoPinEdgeToSuperviewEdge:ALEdgeLeft