cgcontext

How to use NSUndoManager with a UIImageView or CGContext

拈花ヽ惹草 提交于 2019-12-22 08:45:00
问题 I have an app that uses cgcontext to draw things onto a UIImageView that the user draws using touch events, and I want to be able to undo the drawings made by the user. Edit: I am trying to use my touchesBegan to save theUIImage at the begining of a touch to the NSUndoManager And then how do I use it to undo using a UIAlertView. Meaning, I want to call a method from my UIAlertView that undo's then another that will redo, but I don't know how to accomplish this. Please help 回答1: I write

Using NSString's drawAtPoint method in place of CGContextShowGlyphsAtPoint problems

倾然丶 夕夏残阳落幕 提交于 2019-12-21 08:01:27
问题 In my app I'm trying to render text along a path; this is fine for most characters but not for Japanese (or anything non mac-Roman). I've been advised to use [NSString drawAtPoint] which displays the correct characters in my CATiledLayer; however, they dissapear after approximately 5 seconds. In this time I can zoom the layer and they scale properly, but they don't seem to get committed to the CATiledLayer like the rest of the text usually is. Before I render, I check the string and decide

Using NSString's drawAtPoint method in place of CGContextShowGlyphsAtPoint problems

夙愿已清 提交于 2019-12-21 08:01:02
问题 In my app I'm trying to render text along a path; this is fine for most characters but not for Japanese (or anything non mac-Roman). I've been advised to use [NSString drawAtPoint] which displays the correct characters in my CATiledLayer; however, they dissapear after approximately 5 seconds. In this time I can zoom the layer and they scale properly, but they don't seem to get committed to the CATiledLayer like the rest of the text usually is. Before I render, I check the string and decide

Drawing around CGContextRef to remove pixelation

佐手、 提交于 2019-12-21 05:54:29
问题 Currently, I am having a graphical issue with drawing small dots. I notice that in most professional Calendar applications, the events calendar indentifier is a small dot whose color is the events calendar color. I am current at the point of my application where I need to draw a BETTER dot. Heres a photo of what I mean. It may not be noticeable here but the colored dot is pretty pixelated when its on my phone. I would like to remove the pixelation. I went through a tutorial from Ray

Custom CALayer - invalid context 0x0

余生颓废 提交于 2019-12-21 05:38:11
问题 I'm trying to build an app that use layers, my app structure is UIView --> UIScrollView --> UIView --> LayersView (Custom UIView) --> UIImageView I want to add multiple layers to the LayersView, so I've build a custom CALayer that use UIBezierPath to draw a set of points. CALayerBezierPath.h #import <QuartzCore/QuartzCore.h> @interface CALayerBezierPath : CALayer { NSMutableArray *pointsArray; } @property (nonatomic, retain) NSMutableArray *pointsArray; - (void) initVariables; - (void)

When drawing an arc using CGContextAddArcToPoint(), what does (x1,y1) and (x2,y2) mean?

▼魔方 西西 提交于 2019-12-20 12:28:20
问题 You can use the following code to draw an arc using Quartz: CGContextMoveToPoint(context2, x, y); CGContextAddArcToPoint(context2, x1, y1, x2, y2, r); In these functions, (x,y) is the starting point and r is the arc radius but what are (x1,y1) and (x2,y2) ? 回答1: http://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGContext/Reference/reference.html#//apple_ref/c/func/CGContextAddArcToPoint x1 : The x-value, in user space coordinates, for the end point of the first

CALayer vs CGContext, which is a better design approach?

夙愿已清 提交于 2019-12-20 10:37:17
问题 I have been doing some experimenting with iOS drawing. To do a practical exercise I wrote a BarChart component. The following is the class diagram (well, I wasnt allowed to upload images) so let me write it in words. I have a NGBarChartView which inherits from UIView has 2 protocols NGBarChartViewDataSource and NGBarChartViewDelegate. And the code is at https://github.com/mraghuram/NELGPieChart/blob/master/NELGPieChart/NGBarChartView.m To draw the barChart, I have created each barChart as a

How can I render line faster than CGContextStrokePath?

眉间皱痕 提交于 2019-12-20 09:24:49
问题 I'm plotting ~768 points for a graph using CGContextStrokePath. The problem is that every second I get a new data point, and thus redraw the graph. This is currently taking 50% CPU in what's already a busy App. Graph drawing is done in drawRect in a UIView. The graph is time based, so new data points always arrive on the right hand side. I'm thinking a few alternative approaches: Draw with GLKit (at cost of not supporting older devices) and seems like a lot of work. Do some kind of screen

Erasing on UIImageView

落爺英雄遲暮 提交于 2019-12-20 08:52:45
问题 How can I erase content on front UIImage by swiping finger on it and display UIImage that is back side of UIView. I had used following code in - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event to erase front image: -(void)eraseDrawingContents { UIGraphicsBeginImageContext(frontImage.frame.size); [frontImage.image drawInRect:CGRectMake(0, 0, frontImage.frame.size.width, frontImage.frame.size.height)]; CGContextSaveGState(UIGraphicsGetCurrentContext());

Eraser the drawing in iOS

我们两清 提交于 2019-12-20 07:13:06
问题 I am working on a drawing app, I have a UIBezeirPath, with which I draw in touchesMoved, and convert it to CGPath and then draw on to CGlayer, Here is my code -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { self.currentPath = [[DrawingPath alloc] init]; if(m_eraseButtonClicked) { [self.currentPath setPathColor:[UIColor backgroundColor]]; } else { [self.currentPath setPathColor:self.lineColor]; } CGPathRef cgPath = self.currentPath.path.CGPath; mutablePath =