Change background color in UIScrollView?

How to change black / gray color to white?

This is just a UIView view associated with the UIViewControllers property along with a webview that populates the UIView.

UPDATE

Here is the code that works:

- (void)loadView { UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 416.0f)]; [webView setBackgroundColor:[UIColor whiteColor]]; self.view = webView; [webview release]; } 

Thanks in advance.

iPhone

+4
source share
2 answers

You can use the UIScrollView backgroundColor property to achieve this goal, caption:

 @property(nonatomic, copy) UIColor *backgroundColor 

To change it to white, you should use:

 [myScrollView setBackgroundColor:[UIColor whiteColor]]; 
+11
source

A few improvements for your code:

 - (void)viewDidLoad { [super viewDidLoad]; UIWebView *webview = [[UIWebView alloc] initWithFrame:CGRectMake(self.view.bounds)]; [webView setBackgroundColor:[UIColor whiteColor]]; [self.view addSubview: webView]; [webview release], webview = nil; } 

In general, you should find this approach less fragile.

PS. If you keep a link to the UIWebView around, be sure to release it at - viewDidUnload .

0
source

Source: https://habr.com/ru/post/1333995/


All Articles