2012-05-26 28 views
2

在適用於iPhone的Titanium中,可以在導航欄上方顯示某些內容 - 或者只是禁用導航欄的always-top屬性?在Titanium中覆蓋導航欄的always-top屬性

這是它的外觀,現在The actual state of the app

這是實際的Photoshop實物模型部分: Photoshop-Mockup

的代碼片段調用此是:

var win1 = Titanium.UI.createWindow({ 
     title: 'Home', 
     navBarHidden: false, 
     barImage: 'topbar.png', 
     backgroundImage: 'bga.png' 
}); 
c = Titanium.UI.createImageView({ 
     image: 'logobar.png', 
     top: -13, 
     right: 7, 
     width: 74, 
     height: 108, 
     exitOnClose: !0 
}) 
try { 
     win1.add(c); 
     c.animate({zIndex:3}); 
     win1.addEventListener('focus', function() { 
       Titanium.App.Analytics.trackPageview('/win1') 
     }); 
}catch(e){ 
     alert(e); 
} 

try-catch的實現是因爲我不相信.animate的存在,但它確實存在但沒有奏效。

回答

2

應答(或也許不是它應該是什麼樣子)

鈦本身不支持操縱zIndex的或者說ontop的-性質的特徵。但是,我找到了一個解決方法,允許顯示疊加層。

Screenshot: How it'll look like

這種解決方法的工作原理是鈦處理Windows的方式。首先,我們定義主窗口(例如win1)並填寫它。然後我們創建一個助理窗口(例如win1a)並將ImageView分配給它。然後我們把新窗口放在另一個窗口的頂部,並且聲音。

var win1 = Titanium.UI.createWindow({ 
      title: "*******", 
      navBarHidden: false, 
      barImage: 'topbar.png', 
      backgroundColor: "gray", 
    }); 
    var win1l = Titanium.UI.createWindow({ 
      title: "", 
      navBarHidden: true, 
      height: 84, 
      width: 64, 
      right: 0, 
      top: 0 
    }); 
// Inject ImageView into top-most window 
    win1l.add(Titanium.UI.createImageView({ 
      image: "logobar.png", 
      top: 2, 
      right: 5, 
      width: 60.3, //74, // 74/108 = 0.6851851852 
      height: 88, //108, // ((108-20)*(74/108)) = 60.29629 ~ 60.3 
      exitOnClose: !0 
    })); 
    win1l.open(); 

我希望這可能對您有幫助。

謝謝,-Kenan。

+0

我不需要這個,但它是一個非常聰明的解決方案 – bharal