UIRefreshControl on iOS7 translucent navigation bar
When using the UIRefreshControl on iOS 7 translucent navigation bar, the refresh spinner is located right under the translucent nav bar.
First extends UIRefreshControl,
then override the layoutSubView method
// getting containing scrollView
UIScrollView *scrollView = (UIScrollView *)self.superview;
// saving present top contentInset, because it can be changed by refresh control
if (!topContentInsetSaved) {
topContentInset = scrollView.contentInset.top;
topContentInsetSaved = YES;
// saving own frame, that will be modified
CGRect newFrame = self.frame;
// if refresh control is fully or partially behind UINavigationBar
if (scrollView.contentOffset.y + topContentInset > -newFrame.size.height) {
// moving it with the rest of the content
newFrame.origin.y = -newFrame.size.height;
// if refresh control fully appeared
// keeping it at the same place
newFrame.origin.y = scrollView.contentOffset.y + topContentInset;
// applying new frame to the refresh control
As well as declare this in the .m file
@implementation MyRefreshControl {
BOOL topContentInsetSaved;
Final step, in that table view controller, in the viewDidLoad or somewhere else, put this:
self.refreshControl = [[MyRefreshControl alloc] init]; // create the new instance
[self.refreshControladdTarget:selfaction:@selector(pullToRefresh:) forControlEvents:UIControlEventValueChanged]; // add the event to refresh, like getting data from other sources
self.tableView.contentInset = UIEdgeInsetsMake(20 + 44, self.tableView.contentInset.left, self.tableView.contentInset.bottom, self.tableView.contentInset.right); // 20 for status bar, 44 for navigation bar
// of course need to check if the status bar becomes 44 when phone call comes)
That's it. Hope apple has documented this officially.
Solution credits: Anthony Dmitriyev
Sources: http://stackoverflow.com/questions/12913208/uitableview-with-uirefreshcontrol-under-a-semi-transparent-status-bar