13

New in iOS 8 is a separatorEffect property, to which you are allowed to assign a UIVisualEffect. Has anyone figured out what this is for? I've tried it and I don't see it as having any, uh, visual effect.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Sorry, didn't see this for some reason. - Having the github project to play with was a big help, thanks. – matt Apr 25 '15 at 15:20

3 Answers3

23

I was wondering the exact same thing so I put a Github project together for anyone facing the same issue.

The basic idea is that if your tableView's backgroundView consists of a UIVisualEffectView with a blur effect, then setting the seperatorEffect to a Vibrant Effect with the same blur as the UIVisualEffectView will produce the effect we see in Notification Center where the separators seem transparent.

Something like this:

tableView.separatorEffect = UIVibrancyEffect(forBlurEffect: blurredBackgroundView.blurView.effect as UIBlurEffect)

will produce a table view like this:

enter image description here

Daniel Galasko
  • 23,617
  • 8
  • 77
  • 97
4

Start by watching session 419 from this year's WWDC: "Advanced Graphics and Animations for iOS Apps", they explain how the new visual effect classes work.

I have a UITableViewController in my app that I use as a modal popover. The parent view controller gets blurred by a UIVisualEffectView with a UIBlurEffect, while the table view separators have a UIVibrancyEffect set as effect. On my iPhone 5, it looks like this: Screenshot of modal popover

This is what that same view looks like if separatorEffect is nil: enter image description here

You could, of course, apply a UIBlurEffect to the separators, but that would most likely just be a waste of resources.

Note: Don't actually do what I did in this example. UIVibrancyEffect is very expensive. Just applying a UIVibrancyEffect to this table view's separators caused my app to miss the 60 FPS target on an iPhone 5.

Also note that the Reduce Transparency option under the Accessibility section in Settings.app is a thing and causes UIBlurEffects to be rendered as a solid color. Always check before instancing any UIVisualEffects. Here's some keywords for you to google: UIAccessibilityIsReduceTransparencyEnabled() and UIAccessibilityReduceTransparencyStatusDidChangeNotification

Hope I could help you.

Peter W.
  • 2,323
  • 4
  • 22
  • 42
  • I didn't say I didn't know "how the new visual effect classes work". I do know. What I don't understand is what the UITableView `separatorEffect` does. I don't see it doing anything in my tests, and I don't see it doing anything in your screen shot either. – matt Oct 06 '14 at 21:31
  • That's why I suggested you watch the WWDC session mentioned above. I've added another screenshot showing how the view looks like with no separator effect. – Peter W. Oct 06 '14 at 22:23
1

As both answers have said, the only effect this is intended for is a vibrancy effect when the background of the table is a blur effect. The difference with and without the effect can be subtle:

enter image description here

enter image description here

matt
  • 515,959
  • 87
  • 875
  • 1,141