Ahmadreza
Ahmadreza

Reputation: 7212

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

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.

Upvotes: 15

Views: 12424

Answers (5)

user3151675
user3151675

Reputation: 58019

This is GaétanZ's answer using Swift and Dynamic. (watchOS 7+)

let app = Dynamic.PUICApplication.sharedPUICApplication()
app._setStatusBarTimeHidden(true, animated: false, completion: nil)

This is using a private API, avoid using it in apps intended for the App Store. However, there is a trick...

The only App Store app that I know of and does hide the clock is Clockology. It uses a .clock file obtainable from an outside source and that .clock file makes the clock in the corner invisible (possibly by calling a function already existing in the app, containing code similar to the one above).

Upvotes: 8

GaétanZ
GaétanZ

Reputation: 4930

@Jesús A. Álvarez's answer did not work for me on watchOS 6. I used instead:

@interface PUICApplication : NSObject
+ (instancetype)sharedPUICApplication;
- (void)_setStatusBarTimeHidden:(_Bool)arg1 animated:(_Bool)arg2 completion:(void (^)(void))arg3;
@end

@implementation TSWatchKitExtension

+(void)hideClockTime {
    PUICApplication * application = [NSClassFromString(@"PUICApplication") sharedPUICApplication];
    [application _setStatusBarTimeHidden:YES
                                animated:NO
                              completion: nil];
}
@end

Ofc don't try to use it in production.

Upvotes: 4

On watchOS 6, it can be achieved by overriding CLKTimeFormater's timeText method. As with other methods, this is private API, so you shouldn't use it on apps you intend to publish.

+ (void)hideTime {
    Class CLKTimeFormatter = NSClassFromString(@"CLKTimeFormatter");
    if ([CLKTimeFormatter instancesRespondToSelector:@selector(timeText)]) {
        Method m = class_getInstanceMethod(CLKTimeFormatter, @selector(timeText));
        method_setImplementation(m, imp_implementationWithBlock(^NSString*(id self, SEL _cmd) { return @" "; }));
    }
}

Upvotes: 1

Alexis C.
Alexis C.

Reputation: 4918

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

Upvotes: 2

user4151918
user4151918

Reputation:

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.

Upvotes: 9

Related Questions