更改NavigationBar V形和标题颜色无效

时间:2016-06-05 15:38:34

标签: ios iphone uinavigationcontroller uinavigationbar

我正在尝试设置导航栏的后退按钮和后退按钮的V形颜色。

我的应用程序以导航控制器开始。

此导航控制器具有以下行的自定义类:

- (void)awakeFromNib {
  [super awakeFromNib];

  UIColor *white = [UIColor whiteColor];
  [self setTintColor: white];
//  [self setBarTintColor: white];

  UIFont *fonte = [UIFont fontWithName:@"Avenir-Book" size:14.0f];
  NSDictionary *atributos =  @{NSForegroundColorAttributeName : white,
                               NSFontAttributeName : fonte
                               };

  [self setTitleTextAttributes:atributos];

}

该导航控制器的根视图控制器隐藏了导航栏。此根视图控制器称为主屏幕。

从该视图控制器中我推出另一个可见导航栏的控制器。那个导航栏没有我添加的后退按钮,但iOS在后面放了一个后退按钮和一个V形符号"<主屏"。那个按钮和雪佛龙都回来了。

Aren这些应该尊重导航栏类的设置,使这些项目变白?

有什么问题?

1 个答案:

答案 0 :(得分:1)

要全局设置该颜色,您可以在AppDelegate中使用类似的内容:

-1

或者在Swift中:

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.EventQueue;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.util.Random;
import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

/**
 * @see http://stackoverflow.com/a/37644011/230513
 * @see http://stackoverflow.com/a/36392696/230513
 * @see http://stackoverflow.com/a/36243395/230513
 */
public class CardPanel extends JPanel {

    private static final Random r = new Random();
    private static final JPanel cards = new JPanel(new CardLayout());
    private final String name;

    public CardPanel(String name) {
        super(new GridLayout(0, 1));
        this.name = name;
        this.add(new JLabel(name, JLabel.CENTER));
        JTable table = new JTable(new String[][]{
            {"A0", "B0"}, {"A1", "B1"}
        }, new String[]{"A", "B"});
        this.add(table);
        JLabel label = new JLabel("None", JLabel.CENTER);
        this.add(label);
        table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    label.setText("Selected row: " + table.getSelectedRow());
                }
            }
        });
    }

    @Override
    public String toString() {
        return name;
    }

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                create();
            }
        });
    }

    private static void create() {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        for (int i = 1; i < 9; i++) {
            CardPanel p = new CardPanel("Table " + String.valueOf(i));
            cards.add(p, p.toString());
        }
        JPanel control = new JPanel();
        control.add(new JButton(new AbstractAction("\u22b2Prev") {

            @Override
            public void actionPerformed(ActionEvent e) {
                CardLayout cl = (CardLayout) cards.getLayout();
                cl.previous(cards);
            }
        }));
        control.add(new JButton(new AbstractAction("Next\u22b3") {

            @Override
            public void actionPerformed(ActionEvent e) {
                CardLayout cl = (CardLayout) cards.getLayout();
                cl.next(cards);
            }
        }));
        f.add(cards, BorderLayout.CENTER);
        f.add(control, BorderLayout.SOUTH);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setVisible(true);
    }
}