iOS小技巧--- IOS7 IOS8 界面适配 及 导航栏NavigationBar设置

- (void) setNavigationBar{字体

    if ([[[UIDevice currentDevice]systemVersion] floatValue] >= 7.0) {
spa

        self.edgesForExtendedLayout = UIRectEdgeNone;orm

        self.automaticallyAdjustsScrollViewInsets= NO;图片

    }ci

   UILabel *  titleLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0 , 100, 44)] autorelease];
get

    titleLabel.backgroundColor = [UIColor clearColor];  //设置Label背景透明it

    titleLabel.font = [UIFont boldSystemFontOfSize:20];  //设置文本字体与大小io

    titleLabel.textColor = [UIColor whiteColor];  //设置文本颜色select

    titleLabel.textAlignment = NSTextAlignmentCenter;float

    titleLabel.text = @"约炮神器";  //设置标题

    self.navigationItem.titleView = titleLabel; //只是是 UIVIEW均可以设置不必定是Label


//设置nav背影图片,图片高度为44时,在AppDelegate中设置白色字体,有经典的黑底白字效果

    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"High-44"] forBarMetrics:UIBarMetricsDefault]; 

 // [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; //设置状态栏字体为白色


    UIBarButtonItem * moreButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"更多" style:UIBarButtonItemStylePlain target:self action:@selector(more:)];

    [moreButtonItem setTintColor:[UIColor whiteColor]];

    self.navigationItem.rightBarButtonItem = moreButtonItem;

    UIBarButtonItem * cityButtonItem = [[UIBarButtonItem alloc] initWithTitle:self.locationCity style:UIBarButtonItemStylePlain target:self action:@selector(goCityTable:)];

    self.navigationItem.leftBarButtonItem = cityButtonItem;

    [cityButtonItem setTintColor:[UIColor whiteColor]];

}

相关文章
相关标签/搜索