cgcontext

PDF Generation From UIScrollView + iphone

本小妞迷上赌 提交于 2019-12-30 05:15:35
问题 I want to generate a pdf of UIScrollView whose content size is near about 320*2000. If I use current graphic image context to capture the scroll view layer, then it only captures the visible part of the scroll view not the whole layer of that scroll view. I am using the below code: -(void)CreatePdf:(id)sender { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *saveDirectory = [paths objectAtIndex:0]; NSString *saveFileName = @"myPDF

Draw a circular segment progress in SWIFT

懵懂的女人 提交于 2019-12-29 07:20:24
问题 I would like to create a circular progress with slices where each slice is an arc. I based my code on this answer: Draw segments from a circle or donut But I don't know how to copy it and rotate it 10 times. And I would like to color it following a progress variable (in percent). EDIT: I would like something like this Any help please Regards 回答1: You could use a circular path and set the strokeStart and StrokeEnd. Something like this: let circlePath = UIBezierPath(ovalInRect: CGRect(x: 200, y

How to convert UIView as UIImage?

纵然是瞬间 提交于 2019-12-29 07:19:12
问题 I am taking screenshot image from currentview.but i want to set frame….don't want to convert fullview as image.I gave frame size..but it takes always Image as fullview..any help please? CGRect rectt = CGRectMake(100, 150,150,200); UIGraphicsBeginImageContext(rectt.size); [self.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageView *imgView = [[UIImageView alloc] initWithFrame:rectt]; 回答1:

Combine all UILabels (with proper origins) into a UIImage

烂漫一生 提交于 2019-12-25 10:29:07
问题 So the app I'm working on lets users write text, and the app translate that text into separate UILabels (one UILabel that only contains the text, and another UILabel that is the same width as the text, but with a transparent color background). I want to combine all the uilabels with the UIImage in the background to create a new UIImage. So far I have the following code, but it does not produce any tangible results and would love anyone's help with this problem:

error when trying to undo Context

非 Y 不嫁゛ 提交于 2019-12-25 07:59:14
问题 i try to undo myContext from save state then after i draw the line i call undo method to restore my context to previous but it report error <Error>: CGContextRestoreGState: invalid context code - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint currentPoint = [touch locationInView:self.view]; UIGraphicsBeginImageContext(self.view.frame.size); [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame

How to draw the vertices on a CGContext CGMutablePathRef?

不羁的心 提交于 2019-12-25 05:08:41
问题 I am drawing a set of connected lines as the user enters clicks to specify vertices. I am build a CGMutablePathRef - (void)addPointToCGMPR: (CGPoint)p forNewPolygon: (BOOL)newPoly { if (newPoly) { CGPathMoveToPoint(cgmpr, NULL, p.x, p.y); } else { CGPathAddLineToPoint(cgmpr, NULL, p.x, p.y); } [self setNeedsDisplay]; } drawRect: is then called after each point is entered, and the context CGMutablePathRef is added to a CGContext for display - (void)drawRect:(CGRect)rect { // Set up a context

CGContext transformation, to extract rotated rect

倾然丶 夕夏残阳落幕 提交于 2019-12-25 04:49:15
问题 My intention is to write a function which can extract a rotated rectangular portion of a larger image. That rotated rectangular portion is described with a center point (from 0,0 to full image width/height) a size, and a rotation angle. I worry that I'm not understanding something about CGContexts. I know that after a rotation, my coordinate space is rotated. This function always works if the angle is 0 and appears to be correct if the angle is small. However, as the angle increases,

Sketch On UIView Within UIScrollView

懵懂的女人 提交于 2019-12-25 04:23:20
问题 I am having an issue when trying to sketch on a UIView that is a child view in a UIScrollView . The problem occurs when you try to sketch on the UIView after it's been zoomed or scrolled on. It seems my sketch code (shown below) does not take into account the zoom or scale of the UIView within the UIScrollView because the lines blur and don't show up where they should. Please let me know if there is something that can be done to my code or provide another solution. - (void)touchesBegan:(NSSet

Drawing with CGContext

蓝咒 提交于 2019-12-25 02:28:40
问题 I'm trying to draw lines through touchesMove: method. Below is my touchesMoved: . UIGraphicsBeginImageContext(self.frame.size); CGContextRef context = UIGraphicsGetCurrentContext(); // context setting CGContextSetLineCap(context, kCGLineCapRound); CGContextSetLineJoin(context, kCGLineJoinRound); CGContextSetLineWidth(context, 2.0); CGContextSetRGBStrokeColor(context, 255, 0, 0, 0.5); CGContextSetBlendMode(context, kCGBlendModeNormal); // drawing CGContextMoveToPoint(context, lastPoint.x,

iphone stroke path used for clipping UIImage

雨燕双飞 提交于 2019-12-24 21:02:31
问题 I'm very new to CoreGraphics (although I've been doing iphone programming for a while) Question, I have this snippet that scales proportionally and clips an UIImage to a circle: -(UIImage *)counterpartImageForSchedule:(Schedule *)counterpartSchedule inSize:(CGSize)size { // This function returns a newImage, based on image, that has been: // - scaled to fit in (CGRect) rect // - and cropped within a circle of radius: rectWidth/2 UIImage *image=[UIImage imageNamed:@"fakeuser1.png"]; // when