如何使用 Xcode 显示图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13696277/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to display an image using Xcode
提问by JLott
I need to know how to display an image using Xcode and Objective-C. I am using Xcode 4.5.2. I would prefer to use an empty application. Thanks.
我需要知道如何使用 Xcode 和 Objective-C 显示图像。我正在使用 Xcode 4.5.2。我更愿意使用一个空的应用程序。谢谢。
回答by iDev
Use UIImageViewto display an image in app.
使用UIImageView在应用程序中显示图像。
It is as simple as this,
就这么简单,
UIImageView *imageView = [[UIImageView alloc] initWithFrame:rect];
imageView.image = [UIImage imageNamed:@"MyImage.png"];
[self.view addSubview:imageView];
You dont need a tutorial just for this. Just go through the documentation and you can figure out rest of the properties.
您不需要为此提供教程。只需阅读文档,您就可以找出其余的属性。