2017-03-08 2 views
0

J'utilise Cordova pour créer une application iOS. Je veux que mon webview soit transparent et derrière lui l'arrière-plan flou du papier peint d'utilisateur. Comme l'application de rappel ios.UIVisualEffects, fond transparent de UIWebView

Je sais qu'il est une question commune, mais je ne l'ai pas trouvé de réponses préciser

Est-il possible?

Dans ma méthode de viewDidLoad j'ajouté ces lignes:

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    self.view.backgroundColor = [UIColor clearColor]; 

    UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; 
    UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect]; 
    blurEffectView.frame = self.view.bounds; 
    blurEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 

    //This line places a dark black background with my app being blurred behind it 
    [self.view addSubview:blurEffectView]; 

    //This line instead just makes background of app plain black (the body of html app is transparent) and not blurred , I guess there is something wrong with view hierarchy maybe? 
    [self.view addSubview:self.webView]; 


    [self.webView setOpaque:NO]; 
    [self.webView setBackgroundColor:[UIColor clearColor]]; 
} 

Merci à l'avance

Répondre

0

L'ordre de mise en couleur de fond WebView et devrait être comme l'opacité cette

[self.webView setBackgroundColor:[UIColor clearColor]]; 
[self.webView setOpaque:NO];