How do I programmatically set the view title? In D8, I have a need to dynamically set the title of a views page display.

I've tried implementing both hook_views_pre_render and hook_views_post_build and setting the value of $view-&gt;build_info['title'], but Drupal seems to be ignoring it when setting the page title.

It seems like the code in Views where the title is set is in Drupal\views\Plugin\views\display\Page::execute()

The #title property on the render array in that method IS receiving my overwritten value from one of my hooks, but it's still ignore and is using the manually specified title on the display config.

What is going on!?
If someone else is looking for an answer, Here is how I achieved this.
I implemented hook_views_pre_render and in this hook, I implemented a method of views class setTitle. This allowed me to set the page title. Here is the complete code.

function MYMODULE_views_pre_render(ViewExecutable $view) {
 if ($view-&gt;id() == 'ABC') {
  $view-&gt;setTitle('MY CUSTOM TITLE');
 }
}


Hope this helps.