С выпуском прошивки 8.0, нет необходимости для получения изображения и размывания его больше. Как указывалось в Andrew Plummer, вы можете использовать UIVisualEffectView с UIBlurEffect.
UIViewController * contributeViewController = [[UIViewController alloc] init];
UIBlurEffect * blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *beView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
beView.frame = self.view.bounds;
contributeViewController.view.frame = self.view.bounds;
contributeViewController.view.backgroundColor = [UIColor clearColor];
[contributeViewController.view insertSubview:beView atIndex:0];
contributeViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;
[self presentViewController:contributeViewController animated:YES completion:nil];
Решение, которое работает до того прошивкой 8
Я хотел бы продлить на ответ rckoenes':
Как подчеркивалось, вы можете создать этот эффект:
- Преобразование базового UIView в UIImage
- Blur the UIImage
- Установите UIImage как фон вашего вида.
Кажется, что много работы, но на самом деле делается довольно просто:
1. Создайте категорию UIView и добавить следующий метод:
-(UIImage *)convertViewToImage
{
UIGraphicsBeginImageContext(self.bounds.size);
[self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
2. Сделайте изображение текущий вид и размойте его с помощью Apple's Image Effect category (download)
UIImage* imageOfUnderlyingView = [self.view convertViewToImage];
imageOfUnderlyingView = [imageOfUnderlyingView applyBlurWithRadius:20
tintColor:[UIColor colorWithWhite:1.0 alpha:0.2]
saturationDeltaFactor:1.3
maskImage:nil];
3. Установите его в качестве фона вашего наложения.
-(void)viewDidLoad
{
self.view.backgroundColor = [UIColor clearColor];
UIImageView* backView = [[UIImageView alloc] initWithFrame:self.view.frame];
backView.image = imageOfUnderlyingView;
backView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
[self.view addSubview:backView];
}
Мне нравится ваш вопрос –
@Ian - вы должны согласиться с ответом Себастьяна Ходжаса – galambalazs