-2

这个调整应该用一个视图覆盖锁屏(确实发生了),并在视图中添加了一个“iOS”按钮(没有)。这是我的代码:

#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

提前致谢!:)

4

1 回答 1

0

在 window visible 之后将 Subviews 添加到 window 。

在这行代码之后添加子视图,然后它就会出现。

[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];
}
于 2013-05-18T15:07:44.100 回答