在iphone中绘制正方形的示例代码或教程

时间:2011-07-10 15:43:23

标签: iphone xcode quartz-graphics

嗨我需要一些帮助,在示例iphone app中绘制正方形。所以,如果有人可以提供教程或源代码,那就太棒了。

3 个答案:

答案 0 :(得分:3)

Drawing and Printing on iOS Guide

中有大量信息

如果你想要样本代码 - 那就是Quartz Demo应用程序

答案 1 :(得分:1)

您可以使用这个非常有用的链接:http://www.ifans.com/forums/showthread.php?t=132024

也为我工作,如果您想知道如何更改颜色,将浮动指定给RGBSetColorStroke,然后使用IBActions更改它们,颜色代码在此处:http://developer.apple.com/library/ios/#documentation/uikit/reference/UIColor_Class/Reference/Reference.html

而且,如果你想用uislider改变厚度,只需制作一个浮子,比如,float = [slider value];然后将该float指定给Thickness行:CGContextSetLineWidth(UIGraphicsGetCurrentContext()

OK!

答案 2 :(得分:1)

代码:

    UIGraphicsBeginImageContext(self.view.frame.size);
[paintingImage.image drawInRect:self.view.frame];
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 10);
CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(), [UIColor    whiteColor].CGColor);
CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, 200, 200));
paintingImage.image=UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

关于制作彩虹光晕的视频应用:http://www.youtube.com/watch?v = HGxf1Lity3k

相关问题