標籤:
XE8 實現 iOS 狀態列的幾種效果:
一、狀態列底色:
- 開一個新工程。
- 設定 Fill.Color 顏色屬性。
- 設定 Fill.Kind = Solid。
- 無需修改任何官方源碼。
二、隱藏狀態列(全屏):
- 開一個新工程。
- 設定 BorderStyoe = None。
- 無需修改任何官方源碼。
三、透明狀態列(能見底圖):
- 開一個新工程。
- 設定底圖 Fill.Bitmap.Bitmap。
- 設定 Fill.Bitmap.WrapMode = TitleStretch。
- 設定 Fill.Kind = Bitmap。
- 設定 BorderStyle = ToolWindows。(利用設定此項來顯示透明效果,請見下方源碼修改)
- 需要 FMX.Platform.iOS.pas 源碼。
iOS 5.x 與上述做法相同,只需再多加一個設定:
Project > Options > Version Info (在表格上按滑鼠右鍵來增加)
| Key |
Value |
| UIStatusBarStyle |
UIStatusBarStyleBlackTranslucent |
修改方法:
請將源碼 FMX.Platform.iOS.pas 複製到自己的工程目錄裡,再進行修改。
找到 TPlatformCocoaTouch.CalculateFormViewFrame 加入下面代碼:
function TPlatformCocoaTouch.CalculateFormViewFrame(const AForm: TCommonCustomForm): NSRect;var Orientation: NSUInteger; StatusBarHeight: Single; Tmp: Single;begin if IsPopupForm(AForm) then Result := CGRectMake(AForm.Left, AForm.Top, AForm.Width, AForm.Height) else begin Result := FMainScreen.bounds; StatusBarHeight := 0;{+++>} // 加入下面代碼 if AForm.BorderStyle = TFmxFormBorderStyle.ToolWindow then begin StatusBarHeight := 0; FStatusBarHeight := 0; Result.origin := CGPointMake(0, 0); end else{<+++} // 加入上面代碼 if AForm.BorderStyle <> TFmxFormBorderStyle.None then begin... 略 ...end;
XE8 for iOS 狀態列的幾種效果