美文网首页工作生活
iOS Home键App切换时的隐私保护

iOS Home键App切换时的隐私保护

作者: iOS_July | 来源:发表于2019-07-01 11:01 被阅读0次
UC
T1-> 上图为UC 在APP切换时的一个保护效果,这个功能的作用域是:

当用户使用完app之后,一般会自然的切到后台,不会立即主动的Kill掉app,这种情况下,如果用户刚好停留在敏感数据页面,比如账户、余额、以及什么不可描述的页面,有旁人在的话,就会有点小尴尬啦,这时候就用得到该功能啦

T2-> 方案:
  1. 在AppDelegate的 applicationDidEnterBackground 代理方法中,给当前页面加上一层蒙板
  2. 然后在 applicationWillEnterForeground 代理方法中再移除蒙板.
T3->代码:
#define ProtectUserPrivacy @"ProtectUserPrivacy"
  • 属性
/** 隐私保护萌版*/
@property (nonatomic, strong) UIView *masksView;
  • 代理
- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    //查看是否开启隐私保护
    NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
    NSString *protectStr = [userDefault objectForKey:ProtectUserPrivacy];
    if ([protectStr isEqualToString:@"1"]) {//如 开启了,则创建萌版
        
        UIView *masksView = [[UIView alloc]init];
        masksView.backgroundColor = [UIColor blackColor];
        masksView.frame = self.window.bounds;
        [self.window addSubview:masksView];
        self.masksView = masksView;
        
        UILabel *remindsLab = [[UILabel alloc]init];
        remindsLab.text = @"为您的隐私保驾护航!";
        remindsLab.textAlignment = NSTextAlignmentCenter;
        remindsLab.textColor = [UIColor whiteColor];
        remindsLab.font = [UIFont systemFontOfSize:20 weight:UIFontWeightBold];
        remindsLab.frame = CGRectMake(0, 100, self.window.bounds.size.width, 40);
        [masksView addSubview:remindsLab];
    }
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
    
    //移除萌版
    [self.masksView removeFromSuperview];
}

  • 打开/关闭 App切换时隐私保护
- (IBAction)clickBtn:(UIButton *)sender {
    if (sender.tag == 0) {//打开保护
        
        NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
        [userDefault setObject:@"1" forKey:ProtectUserPrivacy];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }else if (sender.tag == 1){//关闭
        NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
        [userDefault setObject:@"0" forKey:ProtectUserPrivacy];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
}

T4->效果
close
open

相关文章

  • iOS Home键App切换时的隐私保护

    T1-> 上图为UC 在APP切换时的一个保护效果,这个功能的作用域是: 当用户使用完app之后,一般会自然的切到...

  • OC仿支付宝返回到后台添加模糊效果

    最近在使用支付宝的过程中发现当支付宝运行在手机后台,我们双击Home键切换app的时候,支付宝为了保护用户隐私会添...

  • Android修改字体导致fragment事物hide,show

    1.现象进入app,home键,然后修改手机字体大小,再进入app,点击切换tab,切换fragment出现各种重...

  • iOS background执行详解

    大家都知道,当用户点击iPhone的Home键时,iOS会把当前的app转移到background状态,在b...

  • iOS APP生命周期

    面对每次打开iOS应用时.都是否想到过其App运行过程:从启动到按Home键回到主屏幕,从运行中到按两下Home键...

  • iOS App生命周期初识

    面对每次打开iOS应用时.都是否想到过其App运行过程:从启动到按Home键回到主屏幕,从运行中到按两下Home键...

  • ios开发常用快捷键

    IOS模拟器home键:Command + Shift +H 构建应用程序:Command + B 运行app:C...

  • IOS AppDelegate

    ios程序启动顺序 ·启动程序时顺序:构造函数->程序被激活 ·进入切换程序界面(双击home键)执行:程序即将取...

  • 2、App生命周期及AppDelegate、SceneDeleg

    iOS12及以前 关于App的生命周期中的各个方法 APP常见的操作相应的方法调用顺序 启动app 双击home键...

  • 承德在线隐私政策

    iOS隐私政策 * 《承德在线》隐私政策 承德在线APP尊重并保护所有使用服务用户的个人隐私权。为了给您提供更准确...

网友评论

    本文标题:iOS Home键App切换时的隐私保护

    本文链接:https://www.haomeiwen.com/subject/iyowcctx.html