美文网首页
iOS开发设置状态栏的颜色

iOS开发设置状态栏的颜色

作者: 福将的逆袭 | 来源:发表于2018-04-10 17:52 被阅读0次

//设置状态栏颜色

- (void)setStatusBarBackgroundColor:(UIColor*)color {

    UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];

    if([statusBarrespondsToSelector:@selector(setBackgroundColor:)]) {

        statusBar.backgroundColor= color;

    }

}

- (void)viewDidLoad {

    [super viewDidLoad];

    [self setStatusBarBackgroundColor:KMainColor];

}

导航栏图片不能显示全,去掉导航栏“黑线” 

UIImage*bgImage = [UIImageimageNamed:@"nav_bgnewyear"];

  [self.navigationController.navigationBar setBackgroundImage:[bgImage resizableImageWithCapInsets:UIEdgeInsetsZero resizingMode:UIImageResizingModeStretch] forBarMetrics:UIBarMetricsDefault];

  [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"nav_bgnewyear"] forBarMetrics:UIBarMetricsDefault];

self.navigationController.navigationBar.shadowImage = [UIImage new];

相关文章

网友评论

      本文标题:iOS开发设置状态栏的颜色

      本文链接:https://www.haomeiwen.com/subject/rdvnhftx.html