创建 UIBarButtonItem

//Swift
let barButtonItem = UIBarButtonItem(title: "Greetings!", style: .Plain, target: self, action: #selector(barButtonTapped))
self.navigationItem.rightBarButtonItem = barButtonItem

//Objective-C
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Greetings!" style:UIBarButtonItemStylePlain target:self action:@selector(barButtonTaped)];
self.navigationItem.rightBarButtonItem = barButtonItem;

StackOverflow 文档