美文网首页iOS充电知识点
iOS-InjectionIII UI效果实时更新

iOS-InjectionIII UI效果实时更新

作者: 石显军 | 来源:发表于2019-03-25 10:59 被阅读0次

    作用

    InjectionIII可以让你更改的UI效果实时的在模拟器上显示,无需重新启动应用程序,从而节省开发人员的时间

    使用方法

    1. 在 App Store 下载安装 InjectionIII
    2. 添加相应的代码
      Xcode10之前:
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        
    #if DEBUG
        // iOS
        [[NSBundle bundleWithPath:@"/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle"] load];
        // tvOS
        [[NSBundle bundleWithPath:@"/Applications/InjectionIII.app/Contents/Resources/tvOSInjection.bundle"] load];
        // macOS
        [[NSBundle bundleWithPath:@"//Applications/InjectionIII.app/Contents/Resources/macOSInjection.bundle"] load];
    #endif
        
        // Override point for customization after application launch.
        return YES;
    }
    

    Xcode10之后:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        
    #if DEBUG
        // iOS
        [[NSBundle bundleWithPath:@"/Applications/InjectionIII.app/Contents/Resources/iOSInjection10.bundle"] load];
        // tvOS
        [[NSBundle bundleWithPath:@"/Applications/InjectionIII.app/Contents/Resources/tvOSInjection10.bundle"] load];
        // macOS
        [[NSBundle bundleWithPath:@"//Applications/InjectionIII.app/Contents/Resources/macOSInjection10.bundle"] load];
    #endif
        
        // Override point for customization after application launch.
        return YES;
    }
    
    1. 选择项目文件夹


      image.png

    4.在实时显示的类中添加 代码

    - (void)injected
    {
        NSLog(@"I've been injected: %@", self);
    }
    

    5.更改后com+s 保存 模拟器会实时更新效果

    效果展示

    2019-03-25 10-48-14.2019-03-25 10_56_30.gif

    相关文章

      网友评论

        本文标题:iOS-InjectionIII UI效果实时更新

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