Apple Watch:状态栏高度

11

有人知道苹果手表状态栏的大小吗?

我在苹果手表人机界面指南和苹果手表编程指南中都没有找到这个值。


我认为他们很可能与所有其他屏幕保持一致,使用了“20pts”。 - Izzy
不,我正在测量它。小版本为38px-19pt。 - Vlad Polyanskiy
7个回答

6

6

所以,我已经测量过它们了。

38毫米 - 19pt(38像素)

42毫米 - 21pt(42像素)

这个技巧是设置白色背景并测量从顶部边缘到白色内容开始的距离。希望对某些人有用。


3

适用于Watch系列7或更高版本的状态栏高度:

  • 45mm:高度=35pt(70px)
  • 41mm:高度=34pt(68px)
  • 44mm:高度=31pt(62px)
  • 40mm:高度=28pt(56px)

为什么与1-3系列相比有很大的差异?因为状态栏必须考虑到圆角半径。


这个有官方文档吗? - user1872384
@user1872384 我没有找到任何文档,所以我只是进行了测量。 - Cosmin
也找不到。38毫米:19点(38像素),42毫米:21点(42像素),40毫米:28点(56像素)和44毫米:31点(62像素)。我只能在这个链接中找到这些信息,该链接与您的测量结果对齐:https://medium.com/@hacknicity/how-apps-adapt-to-the-series-4-apple-watch-screen-sizes-2be49f8ae8f5 - user1872384

2

用法

    let currentDevice = WKInterfaceDevice.current()
    let statusBarHeight : CGFloat = currentDevice.statusBarHeight()

扩展

import WatchKit

extension WKInterfaceDevice {

    func statusBarHeight() -> CGFloat {
        
        // current device
        
        let currentDevice = WKInterfaceDevice.current()
        let bounds = currentDevice.screenBounds
        let retinaFactor = currentDevice.screenScale
        
        // dimensions in pixels
        
        let width = bounds.width * retinaFactor
        let height = bounds.height * retinaFactor
        
        // 38mm: statusBar = 19pt (38px), screenBounds: 272 x 340
        
        if width == 272.0 && height == 340.0 {
            
            return 19.0
            
        }
        
        // 40mm: statusBar = 28pt (56px), screenBounds: 324 x 394
        
        if width == 324.0 && height == 394.0 {
                        
            return 31.0
            
        }
        
        // 41mm: statusBar = 34pt (68px), screenBounds: 352 x 430
        
        if width == 352.0 && height == 430.0 {
            
            return 34.0
            
        }
        
        // 42mm: statusBar = 21pt (42px), screenBounds: 312 x 390

        if width == 312.0 && height == 390.0 {
            
            return 21.0
            
        }

        // 44mm: statusBar = 31pt (62px), screenBounds: 368 x 448
        
        if width == 368.0 && height == 448.0 {
            
            return 31.0
            
        }

        // 45mm: statusBar = 35pt (70px), screenBounds: 396 x 484
        
        if width == 396.0 && height == 484.0 {
            
            return 35.0
            
        }
        
        // 49mm: statusBar = 37pt (74px), screenBounds: 410 x 502
        
        if width == 410.0 && height == 502.0 {
            
            return 37.0
            
        }
        
        // default to 38mm
            
        return 19.0
        
    }
    
}

1
如果我想添加一个确切大小的WKInterfaceImage对象。
那么用Adobe Fireworks(或其他图像编辑器)创建的图像必须是什么?
38mm: 高度= 170-19(状态栏高度); 宽度= 136;
42mm: 高度= 195-21(状态栏高度); 宽度= 156;
我说的是@1x的图像(我知道对于@2x或@3x,我必须乘以相应倍数)。

0
实际上,我们可以使用苹果的设计模板来获取最新操作系统的实际信息。

https://developer.apple.com/design/resources/#watchos-apps

根据上面的链接,更新了片段:

import WatchKit

extension WKInterfaceDevice {

    func statusBarHeight() -> CGFloat {

        // current device

        let currentDevice = WKInterfaceDevice.current()
        let bounds = currentDevice.screenBounds
        let retinaFactor = currentDevice.screenScale

        // dimensions in pixels

        let width = bounds.width * retinaFactor
        let height = bounds.height * retinaFactor

        if #available(watchOS 10, *) {
            switch (width, height) {
                    // 40mm: statusBar = 28pt (56px), screenBounds: 324 x 394
                case (324, 394):
                    return 32 //
                    // 41mm: statusBar = 34pt (68px), screenBounds: 352 x 430
                case (352, 430):
                    return 38 //
                    // 44mm: statusBar = 31pt (62px), screenBounds: 368 x 448
                case (368, 448):
                    return 38 //
                    // 45mm: statusBar = 35pt (70px), screenBounds: 396 x 484
                case (396, 484):
                    return 42 //
                    // 49mm: statusBar = 37pt (74px), screenBounds: 410 x 502
                case (410, 502):
                    return 46 //
                    // default to 40mm
                default:
                    return 32
            }
        } else {
            switch (width, height) {
                    // 38mm: statusBar = 19pt (38px), screenBounds: 272 x 340
                case (272, 340):
                    return 19
                    // 40mm: statusBar = 28pt (56px), screenBounds: 324 x 394
                case (324, 394):
                    return 31
                    // 41mm: statusBar = 34pt (68px), screenBounds: 352 x 430
                case (352, 430):
                    return 34
                    // 42mm: statusBar = 21pt (42px), screenBounds: 312 x 390
                case (312, 390):
                    return 21
                    // 44mm: statusBar = 31pt (62px), screenBounds: 368 x 448
                case (368, 448):
                    return 31
                    // 45mm: statusBar = 35pt (70px), screenBounds: 396 x 484
                case (396, 484):
                    return 35
                    // 49mm: statusBar = 37pt (74px), screenBounds: 410 x 502
                case (410, 502):
                    return 37
                    // default to 38mm
                default:
                    return 19
            }
        }
    }
}

0

为了补充缺失的尺寸,这是Apple Watch Ultra

49毫米 - 37pt(74像素)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接