how to change position of anchors in unity ui code example
Example 1: setting the anchor presets unity
newrect.anchorMin = new Vector2(0.5f, 0);
newrect.anchorMax = new Vector2(0.5f, 0);
newrect.pivot = new Vector2(0, 0);
Example 2: unity position ui element
// To get or set the position of a UI element, see below:
GameObject.GetComponent<RectTransform>().anchoredPosition;