Reputation: 193
Hi i need some help for drawing square in sample iphone app.So if someone can provide me tutorial or source code it would be great.
Upvotes: 1
Views: 4435
Reputation: 63
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
Upvotes: 1
Reputation: 41
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!
Upvotes: 1
Reputation: 150635
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
Upvotes: 3