Aleksandar • Vacić

iOS bits and pieces

How to remove UINavigationBar’s bottom border / shadow in iOS 7

One of the most annoying visual things Apple introduced in iOS 7 is inability to remove the navigation bar shadow image. iOS 7 UI is perfect to create seamless transition between the content and the top of the screen.

The only issue is that darn line at the bottom. There is no property on UINavigationBar to hide it. There is shadowImage which allows you to change it, but can’t remove it – shadowImage = nil is the default which shows their default image. Even changing the shadowImage to 100% transparent image is not enough:

For a custom shadow image to be shown, a custom background image must also be set with the setBackgroundImage:forBarMetrics: method. If the default background image is used, then the default shadow image will be used regardless of the value of this property.

Brilliant. 😕 You can remove the shadow only if you also kill the blur, like this:

1
2
3
[self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init]
          forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [[UIImage alloc] init];

Can’t help to think this was not properly thought through, but given the hectic schedule Apple engineers had for iOS 7, something had to give. Anw, with no other avenue left, it’s subview walkthrough time.

Problem: UICollectionViewCell redraw during interactive resize of UICollectionView

I’m very close to finishing the next big update of Unitica. Headline feature is that app is now Universal and I’ve built custom container controller that looks like this:

I added background colors to clearly visualize the various child levels; at the top you have my custom split view controller with two child controllers:

  • category collection view controller
  • columns controller

This ColumnsController has two child controllers (orange and yellow) - each an instance of UnitViewController, which is UICollectionViewController subclass. Green and bluish violet are actual collection view cells. Layout is UICollectionViewFlowLayout subclass where I make sure that cells always span the full width of the collection view.
This is the most relevant part of the layout:

1
2
3
4
5
6
7
8
9
10
11
- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds {
  return YES;
}

- (void)prepareLayout {
  CGFloat w = floor(self.collectionView.bounds.size.width);
  CGSize is = self.itemSize;
  is.width = w;
  self.itemSize = is;
  [super prepareLayout];
}

The problem I have is that I want to allow changing the split position between the CategoryController and ColumnsController. You just drag the divider in the middle to set the sizes as you wish. Or you can slide them all the way to the edge and have one of those full screen.

This simply refuses to obey and I’m out of ideas what to try to force a proper redraw. Here’s the video that illustrates the problem.

The App Store’s slow grind

Last few days, the mood turned way too sombre among iOS app developers. I see it going in cycles, but the worrying trend is that period between those days is getting shorter. This time is was sparked by Jared Sinclair’s post about the sales numbers for one of the best RSS readers on iOS: Unread.

Given the feature placements on the App Store, glowing reviews at prominent blogs - I expected this app to have earned at least 300-400k. Instead, it barely eked out over 40k. For such a quality app, this is really disheartening.

Many people chimed in, before and after with varying thoughts, but frankly - the mood is not good. I may be wrong, but I think that Jared is now in the position where I was about 3-4 years ago, but with way more success and recognition than I had back then and now. Which is fantastic position to bounce up, if he chooses to do so.

Auto layout exception thrown when deleting UICollectionViewCell

I am preparing my main apps to be compatible with iOS 8 and upcoming new devices of possibly varying physical sizes. First order of business: remove any hard-coded 320 values in various places.

In Units convert (note: the upcoming version 3.0 will be called Unitica) I have a very complex cell in the favorites screen.

When you swipe over that cell, you get the option to remove that particular favorited pair; doing that triggers cell removal and adjustment of the position of cells below. And it throws this lovely exception doing that: