Sample code or tutorial for drawing square in iphone
Hi i need some help for drawing square in sample iphone app.So if someone can provide me tutorial or source code it wou开发者_StackOverflow中文版ld be great.
There's plenty of information in the Drawing and Printing on iOS Guide
And if you want Sample Code - there is the Quartz Demo application
You can use this really helpful link: http://www.ifans.com/forums/showthread.php?t=132024
Worked for me, also, if youre wondering how to change colors, assign floats to the RGBSetColorStroke and then change them with IBActions, the color codes are here: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIColor_Class/Reference/Reference.html
And also, if you wanna change the thickness with a uislider, just make a float, say, float = [slider value]; Then assign that float to the Thickness line: CGContextSetLineWidth(UIGraphicsGetCurrentContext()
OK!
Code:
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();
Video on making rainbow glow draw app:http://www.youtube.com/watch?v=HGxf1Lity3k
精彩评论