A dead simple implementation of interactive (stretchable) header images that can easily be added to any UIScrollView, UITableView, UICollectionView, etc. This includes a navigation category to interactivly control the navigation bar transparency with the scroll view.
Import the category:
#import "UIScrollView+InteractiveHeader.h"
In your ViewController:
- (void)viewDidLoad {
[super viewDidLoad];
self.extendedLayoutIncludesOpaqueBars = YES;
[self.tableView addHeaderWithImage:[UIImage imageNamed:@"banner.jpg"] height:300];
[self.tableView.interactiveHeader setUseAlphaFade:YES];
[self.tableView.interactiveHeader setLabelOffset:22];
[self.tableView.interactiveHeader.titleLabel setText:@"A Clever Title"];
[self.tableView.interactiveHeader.subtitleLabel setText:@"Some Sub-text"];
}
Import the category:
#import "UINavigationBar+InteractiveHeader.h"
In your ViewController:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.navigationController.navigationBar setScrollView:self.tableView];
[self.navigationController.navigationBar setScrollTintColor:UIColor.darkTextColor];
}
thats it, your done.
Dana Buehre (CreatureSurvive) cs@creaturecoding.com
© Dana Buehre (CreatureSurvive) 2020