我们知道一些iOS Native应用程序使用我们的主页背景和Blur作为他们自己的背景。如果我们像在自己的应用程序中那样设置背景,我只是好奇吗?
以下是这些应用的背景:
谢谢! :)
答案 0 :(得分:0)
在IOS 8之前,您可以生成如下代码的背景图片:
- (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;
}
在IOS 8之后
// 1
let blurEffect = UIBlurEffect(style: .Light)
// 2
let blurView = UIVisualEffectView(effect: blurEffect)
// 3
blurView.setTranslatesAutoresizingMaskIntoConstraints(false)
view.insertSubview(blurView, atIndex: 0)
有关详细信息,请参阅此精彩教程: http://www.raywenderlich.com/84043/ios-8-visual-effects-tutorial