You can use color attribute to provide color for the text.
It can be done by two ways → using the color static attributes and color class constructor.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ColorDemo : MonoBehaviour {
[SerializeField]
Text infoText;
void Start () {
infoText.text = "Hello World";
infoText.color = Color.red; //Red color using Color class
//Red color using hex value. (255,0,0) => 255/255, 0/255, 0/255) => (1,0,0)
infoText.color = new Color(1f, 0f, 0f);
// Color with opacity value. 1 means opaque and 0 means transparent.
infoText.color = new Color(1f, 0f, 0f, 0.5f);
}
}