Created
May 11, 2016 02:00
-
-
Save lexrus/db892e33216d1cb1e09ef9364162a49e to your computer and use it in GitHub Desktop.
iOS task list hint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// BackgroundHint.m | |
// Zus | |
// | |
// Created by Lex on 4/13/16. | |
// Copyright © 2016 lex.sh. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
#import <UIKit/UIKit.h> | |
@interface BackgroundHint : NSObject | |
@end | |
@implementation BackgroundHint | |
static const UInt8 kBackgroundHintTag = 45; | |
+ (void) load { | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(showHint) | |
name:UIApplicationDidEnterBackgroundNotification | |
object:nil]; | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(hideHint) | |
name:UIApplicationDidBecomeActiveNotification | |
object:nil]; | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(hideHint) | |
name:UIApplicationWillEnterForegroundNotification | |
object:nil]; | |
} | |
+ (UIImageView *) hintImageView { | |
UIImageView *view = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | |
view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | |
view.image = [UIImage imageNamed:@"background_hint"]; | |
view.tag = kBackgroundHintTag; | |
[view setContentMode:UIViewContentModeScaleAspectFill]; | |
return view; | |
} | |
+ (void) showHint { | |
UIView *view = [[UIApplication sharedApplication] keyWindow].subviews.lastObject; | |
[view addSubview: [self hintImageView]]; | |
} | |
+ (void) hideHint { | |
UIView *view = [[UIApplication sharedApplication] keyWindow].subviews.lastObject; | |
UIView *hintView = [view viewWithTag:kBackgroundHintTag]; | |
[hintView removeFromSuperview]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment