-2

This tweak is supposed to cover the lockscreen with a view (which does happen) and add an "iOS" button to the view (which does not). Here's my code:

#import <UIKit/UIKit.h>
#import <SpringBoard/SpringBoard.h>

@interface Themos
-(void)unlock;
@end

%hook SpringBoard
-(void)applicationDidFinishLaunching:(id)application
{
    %orig;

    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(10,10,80,30)];
    [button addTarget:self action:@selector(unlock:) forControlEvents:UIControlEventTouchUpInside];
    [button setTitle:@"iOS" forState: UIControlStateNormal];

    UIWindow* window = [UIApplication sharedApplication].keyWindow;
    UIView *polygonView = [[UIView alloc] initWithFrame: CGRectMake ( 0, 0, 640, 960)];
    polygonView.backgroundColor = [UIColor redColor];
    [window addSubview:polygonView];
    [polygonView addSubview:button];
    [window makeKeyAndVisible];
    [polygonView release];
    [button release];
}

%new(v@:)
-(void)unlock
{
    [self unlockWithSound:YES];
}
%end

Thanks in advance! :)

1 Answers1

0

Add Subviews to window after the window visible .

add subviews after this line of code then it'l appear.

[window makeKeyAndVisible];


-(void)applicationDidFinishLaunching:(id)application
{
    %orig;

    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(10,10,80,30)];
    [button addTarget:self action:@selector(unlock:) forControlEvents:UIControlEventTouchUpInside];
    [button setTitle:@"iOS" forState: UIControlStateNormal];

    UIWindow* window = [UIApplication sharedApplication].keyWindow;
    [window makeKeyAndVisible];
    UIView *polygonView = [[UIView alloc] initWithFrame: CGRectMake ( 0, 0, 640, 960)];
    polygonView.backgroundColor = [UIColor redColor];
    [window addSubview:polygonView];
    [polygonView addSubview:button];
    [polygonView release];
    [button release];
}
Balu
  • 8,470
  • 2
  • 24
  • 41