Anchoring a UI image to the top of another UI image.

I’ve spent many hours failing at this,

I have 2 UI images.

UIImage A increases in size as the player collects items. I am setting the Rectransform.sizeDelta to change it’s size.

Image B does not change in size, but I need the bottom of it to be at the position of the top of UIImage A.

So as Image A’s height increases, I need Image B to stay at that position.

Any help is greatly appreciated.

If i understand your question clearly then:

  1. Create the image B as the child of image A.
  2. Set the anchors of your image B as

Top aligned:
min (0.5,1)
max (0.5,1)
pivot (0.5,1)

{PS: here i am considering that you want it top aligned not top right or top left aligned

for Top left:
min (0,1)
max (0,1)
pivot (0,1)

for Top right:
min (1,1)
max (1,1)
pivot (1,1)

  1. Now once you have done that, drag your image and set the vertical position (PosY in RectTransform) of image equal to the image height of B.