Combine sugar and cornstarch in a pot; mix in milk and apricot nectar. Bring mixture to a boil over medium heat, stirring continually; boil 1 minute.
Whisk 1/2 cup hot milk mixture into egg yolks and then whisk back into pot. Simmer over low heat for 30 to 60 seconds, stirring continually. Take pot off of heat and mix in margarine. Chill, covered 1 to 2 hours.