zoukankan      html  css  js  c++  java
  • iOS7中修改StatusBar的显示颜色

    iOS7中修改StatusBar的显示颜色

    效果图如下:

    在iOS7中想手动修改statusBar的颜色,第一步需要做的就是在plist文件中设置View controller-based status bar appearance值为NO

    第二步就是在代码中实现了,如下所示:

    //
    //  RootViewController.m
    //  statusBar
    //
    //  Copyright (c) 2014年 Y.X. All rights reserved.
    //
    
    #import "RootViewController.h"
    
    @interface RootViewController ()
    
    @end
    
    @implementation RootViewController
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
        self.view.backgroundColor = [UIColor whiteColor];
        
        // 4秒钟之后改变状态
        [self performSelector:@selector(delayRun)
                   withObject:nil
                   afterDelay:4.f];
    }
    
    - (void)delayRun
    {
        // 动画改变背景色
        [UIView animateWithDuration:1 animations:^{
            self.view.backgroundColor = [UIColor blackColor];
        }];
        
        /*
         可以选择的参数
         
         UIStatusBarStyleLightContent
         UIStatusBarStyleDefault
         */
        // 动画改变StatusBar显示颜色
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent
                                                    animated:YES];
    }
    
    @end

    以下是实现细节要注意的地方:

     
  • 相关阅读:
    玩游戏(dfs)
    Find them, Catch them(并查集)
    Shredding Company(dfs)
    Sudoku(dfs)
    Network Saboteur(dfs)
    棋盘问题(dfs)
    Curling 2.0(dfs)
    A Knight's Journey(dfs)
    15. 3Sum
    12. Integer to Roman
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/3962847.html
Copyright © 2011-2022 走看看