2016-11-19 24 views
0

我正在使用Iconic 1,並且希望將「MyAccount」居中放在標題中。我查看了文檔並嘗試了代碼,但它將內容放置在內容窗格中。如何在Ionic應用程序中居中標題

這是我在顯示的「我的帳戶」,在頂部的那一刻得到了代碼:

<ion-view view-title="MyAccount"> 
    <ion-content> 
    <h1>My Account</h1> 
    </ion-content> 
</ion-view> 

我想我需要的地方添加<ion-header-bar></ion-header-bar>指令。我嘗試添加它,但沒有達到預期的效果。

任何人都可以建議如何做到這一點?

enter image description here

回答

3

要使用在離子 - 角的動態標題欄問題,使用<ion-header-bar>指令:

<ion-header-bar 
    title="MyAccount" 
    left-buttons="leftButtons" 
    right-buttons="rightButtons" 
    type="bar-positive" 
    align-title="center"> 
</ion-header-bar> 

來源:Headers

實施例:

<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">MyAccount</h1> 
    <div class="buttons"> 
    <button class="button">Right Button</button> 
    </div> 
</ion-header-bar> 
<ion-content class="has-header"> 
    Some content! 
</ion-content> 
相關問題