How to add a button to UINavigationBar?

后端 未结 7 1737
暖寄归人
暖寄归人 2020-12-02 06:19

How to add a button to UINavigationBar programmatically?

相关标签:
7条回答
  • 2020-12-02 06:57

    Why not use the following: (from Draw custom Back button on iPhone Navigation Bar)

    // Add left
    UINavigationItem *previousItem = [[UINavigationItem alloc] initWithTitle:@"Back title"];
    UINavigationItem *currentItem = [[UINavigationItem alloc] initWithTitle:@"Main Title"];
    [self.navigationController.navigationBar setItems:[NSArray arrayWithObjects:previousItem, currentItem, nil] animated:YES];
    
    // set the delegate to self
    [self.navigationController.navigationBar setDelegate:self];
    
    0 讨论(0)
提交回复
热议问题