问题
I have an UIView (v1):
---------------
| --------- |
| | | |
| | | |
| | | |
| | UIImage | |
| | View | |
| --------- |
| UIView |
---------------
With an UIImageView (img1) as subview.
When I'm going to resize the UIView:
int img1int = v1.frame.size.height+(img1.frame.size.height - img2.frame.size.height);
v1.frame = CGRectMake(v1.frame.origin.x, v1.frame.origin.y, v1.frame.size.width, img1int+20);
The image resize with the view, but I want to just resize the view, and let the image with the normal height.
The int is a calculus that I made, for the UIView has its height related to the height of UIImageView (img1).
Any idea how to resize only the UIView?
Thanks a lot!
回答1:
Turn off "Autoresize Subviews"
on your UIView v1
attributes in the XIB file.
By default this is checked.
This works for your app above. Alternatively, if you wanted some children to auto-resize and some not, then on each child you can disable the auto-size height/width (the red arrows within the "Auto-sizing" box.
Your UIImageView will then stop resizing.
来源:https://stackoverflow.com/questions/9762110/uiview-resizing-but-not-the-subviews