gpt4 book ai didi

ios - 半透明,setStatusBarStyle,UIWebView

转载 作者:行者123 更新时间:2023-12-01 18:16:06 27 4
gpt4 key购买 nike

enter image description here我正在研究 UIWebView,我想要的是 webView 不要过度说唱 View 。

所以这就是问题所在。我设置了 UIWebView ,状态栏覆盖在内容上。
我该如何处理?我在制作 UIImage View 时进行了编码,但当时有导航栏,并且效果很好。

我也做了 setFrame:CGRectMake(0, 20).... 但也不起作用。为什么 [setFrame];方法不行?请有任何想法。

#import "ViewController.h"

@interface ViewController ()

@property (weak, nonatomic) IBOutlet UIWebView *webView;
@end

@implementation ViewController

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault];
[self.webView setFrame:CGRectMake(0,0, self.view.frame.size.width, self.view.frame.size.height)];

NSURL *myURL = [NSURL URLWithString:@"http://www.amazon.com"];
NSURLRequest *myURLReq = [NSURLRequest requestWithURL:myURL];
[self.webView loadRequest:myURLReq];






}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}


-(void)webViewDidStartLoad:(UIWebView *)webView{

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

}


@end

更新:我关闭了自动布局并更改了 setFrame:CGRectMake(0, 20 ) 现在它们没有被覆盖。但我想知道为什么我们需要设置这个?如果我将状态栏设置为 translucent ,这是有道理的。但是我将它设置为默认值,它应该在(0,20)的状态栏正下方开始绘制屏幕。

最佳答案

试试这个

- (void)viewDidLoad
{
[super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.


[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleDefault];

[self.webView setFrame:CGRectMake(0.0, 20.0, self.view.frame.size.width, self.view.frame.size.height)];

NSURL *myURL = [NSURL URLWithString:@"http://www.amazon.com"];

NSURLRequest *myURLReq = [NSURLRequest requestWithURL:myURL];
[self.webView loadRequest:myURLReq];

}

您的自动调整大小蒙版应如下所示。

Your autosize masks should look like this

最终输出:

enter image description here

关于ios - 半透明,setStatusBarStyle,UIWebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21828333/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com