How to hide or remove the time from the Apple Watch status bar?

坚强是说给别人听的谎言 提交于 2019-12-08 17:28:31

问题


How do I hide or remove the small clock from Apple Watch statusbar screen on my app?

I searched the web for this but found nothing!

I just discovered that Apple will reject your app if you remove that clock, but my app is a watch face itself and doesn't need to display that time.


回答1:


As you pointed out, trying to hide or remove the time from the status bar will get your app rejected.

There's no way to accomplish what you want to do yet, since Apple doesn't permit developers to create custom watch faces (even in watchOS 3).

Update:

For your information, the only situation when the time does not appear on the status bar is when a modal presentation has both a left AND a right bar button title. This usually does not occur, but will happen during dictation -- the text input controller shows a Cancel button on the left and a Done button on the right of the status bar.

While hacking the bar titles (or using a private API) wouldn't get your app approved, you might look into a way of "hiding" the status bar itself, or the right title of any other modal view which doesn't happen to show the time.

I'm only pointing these things out in case you simply wanted to make a particular app for your own use. Since Apple will reject apps which violate their requirements, I wouldn't encourage you to waste your time trying to make an app which you know would get rejected.




回答2:


Actually found a way to hide the time overlay on a Github open-source project.

Here is how it's done (in Objc):

#import "InterfaceController.h"
#import "FaceScene.h"

@import ObjectiveC.runtime;
@import SpriteKit;

@interface NSObject (fs_override)
+(id)sharedApplication;
-(id)keyWindow;
-(id)rootViewController;
-(NSArray *)viewControllers;
-(id)view;
-(NSArray *)subviews;
-(id)timeLabel;
-(id)layer;
@end

@implementation InterfaceController

- (void)didAppear
{
    /* Hack to make the digital time overlay disappear */

    NSArray *views = [[[[[[[NSClassFromString(@"UIApplication") sharedApplication] keyWindow] rootViewController] viewControllers] firstObject] view] subviews];

    for (NSObject *view in views)
    {
        if ([view isKindOfClass:NSClassFromString(@"SPFullScreenView")])
            [[[view timeLabel] layer] setOpacity:0];
    }
}

@end


来源:https://stackoverflow.com/questions/38067952/how-to-hide-or-remove-the-time-from-the-apple-watch-status-bar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!