【问题标题】:How to move navigation bar image?如何移动导航栏图像?
【发布时间】:2012-04-26 12:29:49
【问题描述】:

我想将图像设置在导航栏的左侧。我参考了一些教程,但大多数人说 use button image to move the image to left 。是否有任何代码可以将图像作为图像视图而不是按钮图像向左移动?

【问题讨论】:

  • 你能澄清你的问题吗?我只是让你在导航栏的左侧添加图像。
  • 实际上我希望在导航栏的左侧显示一个图像作为图像视图而不是按钮视图。
  • 你可以动态地做到这一点。在导航栏上添加图像视图
  • 但是我不能把它移到左边。有没有代码可以移到左边。如果是这样,请发布
  • 你可以在栏上静态添加imageview,你想要多少屏幕..

标签: iphone xcode uiimageview uinavigationbar


【解决方案1】:

您可以通过在导航栏上添加您的图像视图来做到这一点。请参阅下面的代码它对我来说工作正常

bar = [self.navigationController navigationBar];    
    [bar setBackgroundColor:[UIColor clearColor]];
    barImg=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"navImg.png"]];
    [bar addSubview:barImg];


    tick_img_lbl=[[UIImageView alloc]initWithFrame:CGRectMake(86, 6,34, 33)];
    tick_img_lbl.image=[UIImage imageNamed:@"tick-1.png"];
    [bar addSubview:tick_img_lbl];
    [tick_img_lbl release];

这里的 bar 是 UINavigationBar。我在导航栏中添加图像,然后在指定坐标中添加图像视图。试试这个,如果需要任何澄清,请告诉我..

【讨论】:

    猜你喜欢
    • 2020-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-22
    • 1970-01-01
    • 2017-04-04
    • 1970-01-01
    相关资源
    最近更新 更多