从导航栏删除标题

时间:2016-06-07 06:13:17

标签: objective-c xcode uinavigationcontroller uinavigationbar

我正在使用Navigational Controller,我想删除NavigationalBar上的上一页的标题,如下所示: -

enter image description here

3 个答案:

答案 0 :(得分:2)

您可以使用以下代码行从NavigationBar中删除导航标题:

var env        = require('minimist')(process.argv.slice(2)),
    gulp       = require('gulp'),
    compass    = require('gulp-compass'),
    cssmin     = require('gulp-cssmin'),
    connect    = require('gulp-connect')


gulp.task('js', function(){
    return gulp.src('src/js/**/*.js')
        .pipe(concat('main.js'))
        .pipe(gulp.dest('build/js/'))
        .pipe(connect.reload());
});

gulp.task('html', function(){
    return gulp.src('src/templates/**/*.html')
        .pipe(gulp.dest('build/'))
        .pipe(connect.reload());
});


gulp.task('watch', function(){
    gulp.watch('src/templates/**/*.html',['html']);
    gulp.watch('src/sass/**/*.scss', ['compass']);
    gulp.watch('src/js/**/*.js', ['js']);
    gulp.watch('src/img/**/*.{jpg,png,gif}', ['imagemin']);
});

gulp.task('connect', function() {
    connect.server({
        root: ['build/'],
        livereload: true,
        middleware: function(){
            return [
                modRewrite([
                    '^/$ /index.html',
                    '^([^\\.]+)$ $1.html'
                ])
            ];
        }
    });
});
gulp.task('default', ['js','html','watch','connect']);

希望它会对你有所帮助。

答案 1 :(得分:2)

<强> 1

您也可以使用以下代码进行更改:

[self.navigationItem.backBarButtonItem setTitle:@"Title here"];

如果你想设置后面的按钮标题是空白的...那么只需要在这里放置标题只放置空格

<强> 2

或者这样做:

UIBarButtonItem *btn = [[UIBarButtonItem alloc]init];
btn.title=@"";
self.navigationItem.leftBarButtonItem=btn;

第3

从界面构建器中选择导航项,然后将后退按钮字符串更改为您希望后退按钮显示为的内容。如果你想把它留空,那就放一个空格。

标题颜色

<强> 1

    NSDictionary *titlecolor =@{
NSForegroundColorAttributeName : [UIColor whiteColor]
                               };

分配字典

    [[self navigationItem] setTitle:@"Your Title"];
self.navigationController.navigationBar.titleTextAttributes = titlecolor;

<强> 2

假设您想要redColor

self.navigationController.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor redColor] forKey:NSForegroundColorAttributeName];

背景颜色

[[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:107.0/256.0 green:145.0/256.0 blue:35.0/256.0 alpha:1.0]]; 

答案 2 :(得分:1)

您需要为导航栏项目按钮标题设置空标题 你可以试试这个

[self.navigationItem.backBarButtonItem setTitle:@" "];

OR

您还可以为导航栏项目按钮指定新按钮

UIBarButtonItem *myButton = 
        [[UIBarButtonItem alloc] initWithTitle:@" " 
                                         style:UIBarButtonItemStyleBordered 
                                        target:nil 
                                        action:nil];
[[self navigationItem] setBackBarButtonItem:myButton];