Search code examples
iphoneioscustomizationjailbreaklockscreen

How to add custom views on lock screen?


I am new to develop jailbroaken iphone apps. I'd like to add my own views, such as button, on the lockscreen and do some simple tasks, but i have no idea what api or function to use. Can I do that by using a special template(like writing custom notification widget)? Or add subviews on a specific view?


Solution

  • this is my logos code:

    #import <UIKit/UIKit.h>
    #import <SpringBoard/SBAwayController.h>
    %hook SBAwayController
    - (void)lock
    {
        %orig;
    
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        btn.frame = CGRectMake(10, 100, 280, 50);
        [btn setTitle:@"Hello Notification" forState:UIControlStateNormal];
        UITapGestureRecognizer *singleTap = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(unlock)] autorelease];
        [btn addGestureRecognizer:singleTap];
        [[[objc_getClass("SBAwayController") sharedAwayController] awayView] addSubview:btn];
    
        return;
    }
    %end
    

    when I lock the screen, the button is added to the lockscreen.