- Home /
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.
Answer by Piyush_Pandey · Jul 03, 2019 at 10:40 AM
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) }
3) 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.
Your answer
![](https://koobas.hobune.stream/wayback/20220612204239im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do I scale the Xmax value of a RectTransform 3 Answers
How to animate UI rect transform which works for all resolutions 1 Answer
Converting to "Rect Transform" permanently deleted part of my project 0 Answers
RectTransform returning incorrect rect bounds 0 Answers
Cannot resize UI Panel 1 Answer