0

I am using theos and I am able to %hook to functions throughout the YouTube but I am unable to figure out how to add a UIButton to the view of the YTMainVideoPlayerOverlayView class

This is the class I am hooking on to.

YTMainVideoPlayerOverlayView.h

I was thinking of hooking into any of these methods

- (void)setVideoButtonsForLayout:(int)arg1;
- (void)setPlayerViewLayout:(int)arg1;
- (void)layoutSubviews;
- (id)init;

I also found this, probably when using CGRectMake

- (float)topButtonsXOffset;

Can anyone give me a hint or example, (please) on how to %hook and be able to add UIButton with a delegate please.

Omar
  • 492
  • 4
  • 10

1 Answers1

0

Try this :

 @interface THE_CLASS_YOU_WANT_TO_HOOK : UIView  //or UIViewController if the class you're hooking is a view controller
 -(void)yourMethod:(UIButton *)button;
 @end    


%hook THE_CLASS_YOU_WANT_TO_HOOK

-(void)layoutSubviews //or loadView if you're hooking a view controller{
   %orig;
   UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
   [button setTitle:@"YOUR_BUTTON_TITLE" forState:UIControlStateNormal];
   button.frame = CGRectMake(x,y,hight,width);
    [button addTarget:self action:@selector(yourMethod:) forControlEvents:UIControlEventTouchUpInside];
  [self addSubview:button]; //if you're hooking a view controller use self.view

}
%new;
-(void)yourMethod:(UIButton *)button {

// Do whatever you want when you press the button here.
}
%end