iOS图形库

时间:2013-01-08 14:51:26

标签: iphone objective-c ios macos ipad

我正在研究iOS,我想创建一个小应用程序,它将我的图像放在黑色背景上并添加任何文本。

示例 - http://demotivation.me/images/20130105/d5il8ka359c2.jpg

如何实现它更好?使用哪个图形库?

3 个答案:

答案 0 :(得分:1)

使用标准的iOS SDK功能,操纵UIView和标签 你不希望这样做有什么困难。只需设置一些框架并查看层次结构。

答案 1 :(得分:1)

查看Quartz / Core Graphics的那种绘图(用于学习目的)。 The Quartz 2D Programming Guide是开始更多了解它的好地方。

如果您不是出于学习目的而这样做,您可以使用视图,图像视图和标签轻松完成此操作。设置它可以在Interface Builder中完成(虽然对学习不是很有用)。

答案 2 :(得分:1)

我认为您需要这样简单的代码:

UIView* backgroundView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // create background view with frame of all screen
backgroundView.backgroundColor = [UIColor blackColor]; // set it color

UIImageView* image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]]; // create image view with image you want
image.frame = CGRectMake(10, 10, 300, 300); // set frame, better to set frame in depending of backgroundView frame, because we've got few types of iOS devices with different displays
[backgroundView addSubview:image]; // place created image to background

UILabel* textLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]; // create frame you want with similar way as image
textLabel.backgroundColor = UIColor.clearColor;
[backgroundView addSubview:textLabel];
[self.view addSubview:backgroundView]; // add created backgroundView to your UIViewController's background