1

As we know some iOS Native app use our home page background with Blur as their own background. And I'm just curious if we set background just like they do in our own app?

Here's the background of those app:

Safari

Music

iBooks

Thanks! :)

He Yifei 何一非
  • 2,592
  • 4
  • 38
  • 69

1 Answers1

0

Before IOS 8, you can generate a background image like the following code:

- (UIImage*)getBlurredImage {
    // You will want to calculate this in code based on the view you will be presenting.
    CGSize size = CGSizeMake(200,200);

    UIGraphicsBeginImageContext(size);
    [view drawViewHierarchyInRect:(CGRect){CGPointZero, w, h} afterScreenUpdates:YES]; // view is the view you are grabbing the screen shot of. The view that is to be blurred.
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    // Gaussian Blur
    image = [image applyLightEffect];

    // Box Blur
    // image = [image boxblurImageWithBlur:0.2f];

    return image;
}

After IOS 8

// 1
let blurEffect = UIBlurEffect(style: .Light)
// 2
let blurView = UIVisualEffectView(effect: blurEffect)
// 3
blurView.setTranslatesAutoresizingMaskIntoConstraints(false)
view.insertSubview(blurView, atIndex: 0)

For more details, see this great tutorial : http://www.raywenderlich.com/84043/ios-8-visual-effects-tutorial

  • 1
    And can we use user's home page background? :) – He Yifei 何一非 Jun 23 '15 at 13:16
  • Maybe their app is not getting the user's home page background but actually app's window is transparent. Please check this: http://stackoverflow.com/questions/18924135/ios-7-display-user-wallpaper-as-uiwindow-background But they say that it is not public API or not used anymore – Nermin Ozkiranartli Jun 23 '15 at 13:33
  • IOS native apps can use this private api, but for security reasons, it seems like it is not available for public 3rd party usage. – Nermin Ozkiranartli Jun 23 '15 at 13:36