UIView Frame Size 没有改变 UIImageView 放在里面 [英] UIView Frame Size Didn't Change UIImageView Placed inside it

查看:94
本文介绍了UIView Frame Size 没有改变 UIImageView 放在里面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在框架中制作图片,然后用户可以在运行时调整框架大小.为此,我在主 UIViewController 中创建了一个自定义 UIView,并在此 UIView 中放置了 2 个 UIImageView.在 xCode 的文档大纲窗格中,它的层次结构是:

I'm making a picture in a frame and then user can resize the frame size in runtime. For this purpose I've made a custom UIView in my main UIViewController and inside this UIView I've placed 2 UIImageView. In Document Outline Pane of xCode it's hierarchy is:


视图
|--ImageView
|--ImageView


View
|--ImageView
|--ImageView

我使用这行代码来改变 UIView 在不同条件下的大小,它会相应地调整大小:

I'm using this line of code to change size of UIView under different conditions it'll resize accordingly:

self.imageObject.frame = CGRectMake(self.imageObject.frame.origin.x , 
                                    self.imageObject.frame.origin.y, 
                                    200, 
                                    200);

imageObject 是我的 UIView.当我运行它时,UIView 的大小发生了变化,但 UIImageView 的大小保持不变.我也试过对我的 UIImageView 做同样的事情,但没有奏效.

imageObject is my UIView. When I run it the size of the UIView changes but UIImageView size remains the same. I've also tried doing the same for my UIImageView but it didn't work.

推荐答案

你也可以试试这个 :-

You can also Try This :-

imageView.frame = CGRectMake(0,0,imageObject.frame.size.width, imageObject.frame.size.height);
imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
self.imageShw.contentMode = UIViewContentModeScaleAspectFit;

这篇关于UIView Frame Size 没有改变 UIImageView 放在里面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆