Mark Selby withstood a brave fightback from world No 1 Judd Trump to clinch the third UK Championship title of his career at the Barbican Centre in York.