UI elements are components just like most things you use in unity, so just call AddComponent():
Text text = gameObject.AddComponent();
text.text = "Hello";
↧