如何设置正确的导航栏色调?

时间:2015-02-06 05:20:15

标签: ios background-color uicolor

我正在导航栏中创建标题视图。我设计了我的标题视图,背景视图颜色为R:255 G:182 B:22(在Photoshop上)。在我的故事板中,我将导航栏色调颜色设置为相同的RGB代码,默认样式和半透明选中。

我使用以下方式将我的图像放在导航标题上:

UIImage *titleImage = [UIImage imageNamed:@"Icon-Small-40.png"];
self.navigationItem.titleView = [[UIImageView alloc]initWithImage:titleImage];

当我运行应用程序时,您可以在标题视图中清楚地看到方形图标。标题视图的背景稍暗。我想让背景颜色相同。我觉得它与某些故事板设置有关,但我找不到问题。

3 个答案:

答案 0 :(得分:0)

视图有一个tintColor属性,所以

self.navigationItem.titleView.tintColor = ...

答案 1 :(得分:0)

导航栏色调颜色的答案

partial class DataBrowser
{
    /// <summary> 
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.IContainer components = null;


    #region Component Designer generated code

    /// <summary> 
    /// Required method for Designer support - do not modify 
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
        this.components = new System.ComponentModel.Container();
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DataBrowser));
        this.toolStrip1 = new System.Windows.Forms.ToolStrip();
        this.loadToolStripButton = new System.Windows.Forms.ToolStripButton();
        this.toolStrip1.SuspendLayout();
        this.SuspendLayout();
        // 
        // toolStrip1
        // 
        this.toolStrip1.CanOverflow = false;
        this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
        this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.loadToolStripButton});
        this.toolStrip1.Location = new System.Drawing.Point(0, 0);
        this.toolStrip1.Name = "toolStrip1";
        this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;
        this.toolStrip1.Size = new System.Drawing.Size(216, 25);
        this.toolStrip1.TabIndex = 4;
        this.toolStrip1.Text = "toolStrip1";
        // 
        // loadToolStripButton
        // 
        this.loadToolStripButton.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
        this.loadToolStripButton.Image = global::Sakura.UI.DataBrowsing.Properties.Resources.FormRunHS;
        this.loadToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta;
        this.loadToolStripButton.Name = "loadToolStripButton";
        this.loadToolStripButton.Size = new System.Drawing.Size(53, 22);
        this.loadToolStripButton.Text = "Load";
        this.loadToolStripButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
        this.loadToolStripButton.TextImageRelation = System.Windows.Forms.TextImageRelation.TextBeforeImage;
        this.loadToolStripButton.Click += new System.EventHandler(this.loadToolStripButton_Click);
        // 
        // DataBrowser
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.Controls.Add(this.toolStrip1);
        this.Name = "DataBrowser";
        this.toolStrip1.ResumeLayout(false);
        this.toolStrip1.PerformLayout();
        this.ResumeLayout(false);
        this.PerformLayout();

    }

    #endregion

    protected System.Windows.Forms.ToolStrip toolStrip1;
    protected System.Windows.Forms.ToolStripButton loadToolStripButton;

}

答案 2 :(得分:0)

尝试使颜色匹配起来可能令人抓狂。除了颜色空间问题,API无法保证导航栏的实际颜色与其barTintColor相同。您可能会发现更容易为标题图像提供透明背景。

相关问题