Advertisement
toritoesinocente

Poner una imagen de fondo al webview en Apache Cordova

Jun 28th, 2015
582
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // http://blogsiglo.com/archivo/1951.imagen-de-fondo-en-aplicacion-phonegap-ios-desde-internet-webview-apachecordova.html
  2. #pragma mark UIWebDelegate implementation
  3.  
  4. - (void)webViewDidFinishLoad:(UIWebView*)theWebView
  5. {
  6.     theWebView.opaque = NO; // @ToRo
  7.     UIGraphicsBeginImageContext(self.view.frame.size);
  8.     //estática
  9.     //[[UIImage imageNamed:@"bgs.png"] drawInRect:self.view.bounds];
  10.     //internet
  11.     NSURL* url = [NSURL URLWithString:@"https://www.elsiglodetorreon.com.mx/new/bgs.png"];
  12.     NSData* data = [NSData dataWithContentsOfURL:url];
  13.     UIImage* img = [UIImage imageWithData:data];
  14.     [img drawInRect:self.view.bounds];
  15.     //fin internet
  16.     UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
  17.     UIGraphicsEndImageContext();
  18.  
  19.     // Black base color for background matches the native apps
  20.     theWebView.backgroundColor = [UIColor whiteColor];
  21.     theWebView.backgroundColor = [UIColor colorWithPatternImage: image];
  22.  
  23.     return [super webViewDidFinishLoad:theWebView];
  24. }
  25.  
  26. /* Comment out the block below to over-ride */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement