15

我正在尝试使用 Ionic 在标题栏的中心添加一个徽标。关于如何做的任何建议?

这是我的代码

<ion-nav-bar class="bar-light">
<!--Logo-->
<ion-nav-buttons >
<img class="title" src="https://s3-us-west 2.amazonaws.com/s.cdpn.io/139144/sp_symbol_option2_1.png">
</ion-nav-buttons>
<ion-nav-buttons side="left">
<!--Left icons-->
<button class="button button-icon button-clear ion-navicon" ng-click="toggleLeft()"> 
</button></ion-nav-bar>
4

6 回答 6

21

做这样的事情怎么样:

<ion-header-bar align-title="center" class="bar-positive">
  <div class="buttons">
    <button class="button" ng-click="doSomething()">Left Button</button>
  </div>
  <h1 class="title"><img class="title-image" src="http://www.ionicframework.com/img/ionic-logo-white.svg" width="123" height="43" /></h1>
  <div class="buttons">
    <button class="button">Right Button</button>
  </div>
</ion-header-bar>

你也可以看看这个plunker

他们论坛中的一些额外信息。

于 2014-05-20T09:14:44.750 回答
5

我只是通过以下方式做到了这一点:

在我的模板中 <ion-view title="{{pageTitle}}">

在我的控制器中$scope.pageTitle = "<img src=\"img/logo-290-90.png\">";

于 2015-10-05T20:43:50.697 回答
3

考虑到您正在使用导航栏,您应该使用ion-nav-title。这是一个例子:

<ion-nav-bar align-title="center">
</ion-nav-bar>
<ion-nav-view>
  <ion-view>
    <ion-nav-title>
      <img src="logo.svg">
    </ion-nav-title>
    <ion-content>
      Some super content here!
    </ion-content>
  </ion-view>
</ion-nav-view>
于 2015-12-16T21:26:13.897 回答
2
<ion-view>
    <ion-nav-title>
            <img alt="Company Logo1" height="40" src="img/logo-07.png">
            <img alt="Company Logo2" height="40" src="img/logo-08.png">
    </ion-nav-title>
</ion-view>

根据您的喜好更改图像高度和 src。:)

于 2016-06-06T09:33:50.687 回答
2

将所需的图像放在应用程序的“www/img”文件夹中。然后在 index.html 中使用下面的代码

<h1 class="title"><img class="title-image" src="img/mylogo.png" width="123" height="43" /></h1>
于 2016-07-01T16:32:28.710 回答
0

还可以执行以下操作:

<ion-view  id = "yourHeader">
    <ion-nav-title>
        <div id = "title">YOUR TITLE</div>
        <img src="img/Message.png" class = "peers_msg_img">
        <img src="img/Notification.png" class="peers_profile_img">
        <img src="img/Peers.png" class="peers_alert_img">
     </ion-nav-title>
     <ion-content>
       //Some Content
     </ion-content>
</ion-view>

以下指令是关键:

<ion-nav-title>
于 2017-01-19T05:52:53.153 回答