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]];

}

相關文章
相關標籤/搜索