zoukankan      html  css  js  c++  java
  • XE8 for iOS 状态栏的几种效果

    XE8 实现 iOS 状态栏的几种效果:

    一、状态栏底色:

    1. 开一个新工程。
    2. 设定 Fill.Color 颜色属性。
    3. 设定 Fill.Kind = Solid。
    4. 无需修改任何官方源码。

    二、隐藏状态栏(全屏):

    1. 开一个新工程。
    2. 设定 BorderStyoe = None。
    3. 无需修改任何官方源码。

    三、透明状态栏(能见底图):

    1. 开一个新工程。
    2. 设定底图 Fill.Bitmap.Bitmap
    3. 设定 Fill.Bitmap.WrapMode = TitleStretch
    4. 设定 Fill.Kind = Bitmap
    5. 设定 FullScreen = True
    6. 设定 BorderStyle = ToolWindows。(利用修改源码,让指定為 ToolWindows 来显示透明效果)
    7. 需修改源码 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;

    状态栏下方线 (2015/12/15 补充):

    目前在某些真机的状态栏下方会显示一条线,见下图:

    实测有线:iPhone 6s Plus (只有真机才看的到),(其它皆无此线,如:iPad mini 2, iPhone 4, iPhone 4s)

    问题造成原因:不清楚,猜测应该是 Delphi 的问题(如果在意此问题,请自行去提交 QC)。

    暂时解决方案:

    1. 将 Form.Transparency 设为 True
    2. 放一个 TRectangle 到 Form 里
      1. Rectangle1.Align 设为 Contents
      2. Rectangle1.Stroke.Kind 设为 None
      3. Rectangle1.Fill.Color 设为 $FFFEFEFE
      4. Rectangle1.HitTest 设为 False
    3. 设定好以上,发布到真机,状态栏下方的线就看不见了。
  • 相关阅读:
    mysql 重置root 账户密码
    Applicationpoolidentity 好有趣哦
    类模板的困扰 LNK2019 (转)
    C++中定义比较函数的三种方法
    Spring的AOP,Struts2的拦截器(Interceptor),以及springMVC的(interceptor)
    MyBatis与Hibernate总结篇
    Java中的回调
    闲来重写一下快速排序
    【lucene】一个简单的招聘网站的建立
    【Lucene】小谈lucene的BooleanQuery查询对象
  • 原文地址:https://www.cnblogs.com/onechen/p/4523431.html
Copyright © 2011-2022 走看看