title: How to make play, pause button programmatically in Audio player in ios
body: <p>I am working on <code>AVAudioplayer</code> according to my project requirement.</p>
  
  <p>I am creating play, pause, forward, backward programmatically.</p>
  
  <p>I know how to create forward and backward button programmatically creation.</p>
  
  <p>But I have no idea how to create play and pause buttons(means in audioplayer user click the play button automatically button will display pause button and if click the pause button automatically change the play button.).</p>
  
  <p>how do I handle these two functionalities like play and pause buttons programmatically.</p>
  
  <pre><code>// Play Button creation
  
  
  playButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  
  playButton.frame = CGRectMake(20, 380, 60, 60);
  
  UIImage * buttonImage = [UIImage imageNamed:@“playButton.png"];
  
  [playButton setImage:buttonImage forState:UIControlStateNormal]; 
  
  [playButton addTarget:self action:@selector(playButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
  
  [self.view addSubview:playButton];
  
  
  // Pause Button.
  
  
  pauseButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  
  pauseButton.frame = CGRectMake(130, 380, 60, 60);
  
  UIImage *pauseButton=[UIImage imageNamed:@“pauseButton.png”];
  
  [pauseButton setImage:pauseButton forState:UIControlStateNormal];
  
  [pauseButton addTarget:self action:@selector(pauseButtonPressed:)forControlEvents:UIControlEvents:UIControlEventsTouchUpInside];
  
  [self.view addSubView:pauseButton];
  </code></pre>