How to rotate the gameobject from the center?

I currently wanted to rotate a Unity UI image from its center. But when I rotate from the rotation.z, it will rotate but not from center. Is there a way to solve this?

I found in one of the unity tools which control rotations. When I drag the blue circle, it will rotate the image from the center(position.x and position.y changes relative to the rotation.z). Is there any way to emulate this in the C# script?

154840-rotate-2.png

test this and see if this works for you

public RectTransform rectTransform;
Vector3 pos;

void Start()
{
    rectTransform = GetComponent<RectTransform>();

    pos = rectTransform.rect.center;
    pos = rectTransform.TransformPoint(pos);
}

void Update()
{
    rectTransform.RotateAround(pos, Vector3.forward, 0.1f);
}