1

I have a UIViewController that I am setting as the rootviewcontroller of a UINavigationController. Then in the viewcontroller I create a gmgridview like so:

NSInteger spacing = 15;

GMGridView *gmGridView = [[GMGridView alloc] initWithFrame:self.view.bounds];
gmGridView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

[self.view addSubview:gmGridView];
_gmGridView = gmGridView;

_gmGridView.style = GMGridViewStyleSwap;
_gmGridView.itemSpacing = spacing;
_gmGridView.minEdgeInsets = UIEdgeInsetsMake(spacing, spacing, spacing, spacing);
_gmGridView.centerGrid = YES;
_gmGridView.actionDelegate = self;
_gmGridView.sortingDelegate = self;
_gmGridView.transformDelegate = self;
_gmGridView.dataSource = self;

If I understand this correctly, according to the UI Guide for iOS7 if you use a UINavigationController, it automatically takes care of the view flowing under the statusbar. Which seems to work for the most part of it. Cuz if I do _gmGridView.backgroundColor = [UIColor blackColor]I can see that the gridview does not overflow underneath the statusbar. But when scrolling, the GMGridViewCells go underneath the status bar. I cannot understand why.

This image shows the gridview with the black background color. Notice that the statusbar background isn't black, which tells me that the gridview does not appear behind it.

enter image description here

And this one shows the scrolling

enter image description here

Arsalan Habib
  • 1,395
  • 14
  • 20

1 Answers1

1

In iOS7 that statusbar is transparent. If you don't want things to appear behind the status bar, set the frame of the root view to be approx 30 from the top of the screen and make sure clipsToBounds = YES.

GMGridView *gmGridView = [[GMGridView alloc] initWithFrame:CGRectMake(0,30,self.view.bounds.size.width,self.view.bounds.size.height-30)];
Adam Jenkins
  • 51,445
  • 11
  • 72
  • 100
  • @Adam- The 30px offset is unnecessary when using a UINavgiationController cuz it appropriately adds the offset. – Arsalan Habib Oct 30 '13 at 23:22
  • @bizsytes - you're not actually showing us what background color is black, so, from the code and screenshots you posted, we can't tell that `gmGridView` appears behind the status bar or not (it obviously does). 1) Did you try the code I posted? 2) What about setting `gmGridView.clipsToBounds = YES` – Adam Jenkins Oct 30 '13 at 23:25
  • Umm, I kinda had this in the question which might be what you are looking for "Cuz if I do _gmGridView.backgroundColor = [UIColor blackColor]I can see that the gridview does not overflow underneath the statusbar. But when scrolling, the GMGridViewCells go underneath the status bar." – Arsalan Habib Oct 30 '13 at 23:44
  • So I guess `gmGridView.clipsToBounds = YES` (or `self.view.clipsToBounds = YES`) also does not work? – Adam Jenkins Oct 30 '13 at 23:45