MPMoviePlayerController Add custom Play button

前端 未结 2 801
长情又很酷
长情又很酷 2021-02-03 11:14

Currently i am working on a iPhone Application Which is displaying video. I have used MPMoviePlayController to load the Video from the local folder.

Can we customize th

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-03 12:00

    if you want to have any controlStyle of apple and still want to add some custom buttons on movie view. You can subclass MPMoviePlayerViewController.

    Let say you have MyCustomMoviePlayerViewController as subclass of MPMoviePlayerViewController then in MyCustomMoviePlayerViewController.m

    - (void)viewDidAppear:(BOOL)animated {
         [super viewDidAppear:animated];
         UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [button addTarget:self 
                   action:@selector(aMethod:)
        forControlEvents:UIControlEventTouchUpInside];
        [button setTitle:@"MyCustomButton" forState:UIControlStateNormal];
        button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
        [self.view addSubview :button];
        }
    

提交回复
热议问题