diff --git a/Source/UIScrollView+EmptyDataSet.h b/Source/UIScrollView+EmptyDataSet.h index ddd45aa3..a85ce49d 100644 --- a/Source/UIScrollView+EmptyDataSet.h +++ b/Source/UIScrollView+EmptyDataSet.h @@ -90,6 +90,18 @@ NS_ASSUME_NONNULL_BEGIN */ - (nullable CAAnimation *)imageAnimationForEmptyDataSet:(UIScrollView *)scrollView; +/** + Provides the data source with the means to customize the button that appears + at the bottom of the empty data set. Implementing this method will mean that + any values provided in `-buttonTitleForEmptyDataSet:forState:`, + `-buttonImageForEmptyDataSet:forState:`, and ``buttonBackgroundImageForEmptyDataSet:forState:` + will be ignored. + + @param scrollView A scrollView subclass object informing the data source. + @param button The button that will be displayed at the bottom of the empty data set. + */ +- (void)emptyDataSet:(UIScrollView*)scrollView configureButton:(UIButton*)button; + /** Asks the data source for the title to be used for the specified button state. The dataset uses a fixed font style by default, if no attributes are set. If you want a different font style, return a attributed string. diff --git a/Source/UIScrollView+EmptyDataSet.m b/Source/UIScrollView+EmptyDataSet.m index 27d0a3a7..33f46fdd 100644 --- a/Source/UIScrollView+EmptyDataSet.m +++ b/Source/UIScrollView+EmptyDataSet.m @@ -505,9 +505,12 @@ - (void)dzn_reloadEmptyDataSet if (detailLabelString) { view.detailLabel.attributedText = detailLabelString; } - + // Configure button - if (buttonImage) { + if (self.emptyDataSetSource && [self.emptyDataSetSource respondsToSelector:@selector(emptyDataSet:configureButton:)]) { + [self.emptyDataSetSource emptyDataSet:self configureButton:view.button]; + } + else if (buttonImage) { [view.button setImage:buttonImage forState:UIControlStateNormal]; [view.button setImage:[self dzn_buttonImageForState:UIControlStateHighlighted] forState:UIControlStateHighlighted]; }