UIImage和UIImageView问题 [英] UIImage and UIImageView problem

查看:44
本文介绍了UIImage和UIImageView问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将UIImageView.image属性设置为UIImage无法将图像添加到视图中,但是,如果我设置了imageview frame属性,它可以工作.有人可以告诉我它是如何发生的吗?当我应用UIImage实例方法[drawInRect:]重绘大于视图框架的图像框架时会发生什么?

set a UIImageView.image property to a UIImage is unable add the image to the view,however if i set the imageview frame property,it works.can anyone tell me how it's happen? and what will happen when i apply the UIImage instance method[drawInRect:] redraw the image frame which is larger than the view frame?i have tried but nothing happen,and what is this function doing actual?

推荐答案

通常,它的工作原理是,将图像添加到UIImageView,然后将UIImageView添加到UIView以在屏幕上显示它.您可以以编程方式或使用Interface Builder来执行此操作.(可选)您可以创建一个CGRect(如果需要,可以基于框架),将其用作UIImageView的边界(也可以框架UIView).有几种方法可以做您想做的事.

Generally, how it works is, you add an Image to a UIImageView and then add the UIImageView to a UIView to display it on the screen. You can do this programmatically, or using Interface Builder. Optionally, you can create a CGRect (based on a frame, if you like), use this as the bounds for the UIImageView (or you can frame the UIView). There are several ways to do what you want to do.

不看代码就很难分辨.可能有很多事情.您可能要插入带有在currentView后面的图像的视图?您可能没有保留UIImageView.我们不一定在这里读懂思想(有时我们会读).但是,如果您需要一个可靠的答案,则需要提供更多帮助.

It's hard to tell without seeing your code. It could be a number of things. You could be inserting the view with the image behind the currentView? You may not be retaining the UIImageView. We can't read minds here necessarily, (sometimes we do). But you'll need to be more helpful if you want a solid answer.

或者只是看看这个:

UIImageView文档

这篇关于UIImage和UIImageView问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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