0

我正在使用theos并且我能够在整个 YouTube 中连接到函数,但我无法弄清楚如何将 UIButton 添加到YTMainVideoPlayerOverlayView类的视图中

这是我要上的课。

YTMainVideoPlayerOverlayView.h

我正在考虑使用这些方法中的任何一种

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

我也发现了这个,可能是在使用时CGRectMake

- (float)topButtonsXOffset;

任何人都可以给我一个提示或示例,(请)关于如何 %hook 并能够UIButton与代表一起添加。

4

1 回答 1

0

尝试这个 :

 @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
于 2014-09-02T11:36:10.247 回答