cgcontext

Draw Line using CGContext

♀尐吖头ヾ 提交于 2019-12-04 02:28:19
I want to draw line in table view cell so that I can place textfield & switch in single cell. I increased the height of cell. How can I draw line in cell? I have subclass of UIView which contains following code //Get the CGContext from this view CGContextRef context = UIGraphicsGetCurrentContext(); //Set the stroke (pen) color CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor); //Set the width of the pen mark CGContextSetLineWidth(context, 1.0); // Draw a line //Start at this point CGContextMoveToPoint(context, 10.0, 30.0); //Give instructions to the CGContext //(move "pen"

How to erase finger paint on Custom UIView in iPhone

走远了吗. 提交于 2019-12-03 22:32:58
问题 I have created a custom UIView (without .xib) for a finger paint application. Paint is working fine with custom UIView but my problem is that when I try to erase the painted path I am getting: Error : Invalid context Below is my class: .h file @interface draw2D : UIView { CGPoint previousPoint; CGPoint lastPoint; CGMutablePathRef path; UIButton *btnClose; UIButton *btnErase; BOOL IsErase; } - (IBAction)btnClose:(id)sender; - (IBAction)btnErase:(id)sender; @end @implementation draw2D - (void

Drawing around CGContextRef to remove pixelation

萝らか妹 提交于 2019-12-03 20:48:23
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 Wenderlich's website: Ray Wenderlich Core Graphics . Here is what I got out of it for drawing the dot:

Put border around partially transparent Image being drawn on CGContext

倾然丶 夕夏残阳落幕 提交于 2019-12-03 18:24:25
问题 I have an image with a yellow vase in the foreground and transparent background: I'm drawing it on a CGContext: CGContextDrawImage(context, CGRectMake(0, 0, 100, 100), myImage.CGImage); I can draw a shadow around it by using the following statement before CGContextDrawImage : CGContextSetShadowWithColor(context, CGSizeMake(0,0), 5, [UIColor blueColor].CGColor); But I want to put a stroke around the image, so that it'll looks like following: If I did this: CGContextSetRGBStrokeColor

Iphone How to make context background transparent?

扶醉桌前 提交于 2019-12-03 18:01:12
问题 CALayer *sublayer = [CALayer layer]; /*sublayer.backgroundColor = [UIColor blueColor].CGColor; sublayer.shadowOffset = CGSizeMake(0, 3); sublayer.shadowRadius = 5.0; sublayer.shadowColor = [UIColor blackColor].CGColor; sublayer.shadowOpacity = 0.8;*/ sublayer.frame = CGRectMake(30, 100, 256, 256); sublayer.contents = (id)[[UIImage imageNamed:@"moon.png"] CGImage]; [self.view.layer addSublayer:sublayer]; //self.view.backgroundColor = [UIColor blackColor]; //add moon mask

iOS: How to draw a circle step by step with NSTimer

萝らか妹 提交于 2019-12-03 17:31:12
I'd like to draw a circle without filling (only border of the circle) step by step (like animated timer). 1 spin is equal 1 day (24 hours). I really don't know what to do. Steps I've made 1) I've tried https://github.com/danielamitay/DACircularProgress (it's too wide line of progress) 2) I've tried to draw a circle with many arcs. Can you put me some code please. I really confused. Thanks in advance. EDIT I'd like to use NSTimer because I have a button which allow user to stop drawning a circle. If user touch a button again - drawning will have to continue. David Rönnqvist What I would do is

Custom CALayer - invalid context 0x0

旧街凉风 提交于 2019-12-03 16:55:43
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) addNewPoints:(CGPoint)newPoint; @end CALayerBezierPath.m #import "CALayerBezierPath.h" @implementation

using UIImage drawInRect still renders it upside down

微笑、不失礼 提交于 2019-12-03 16:50:42
I have read some posts on this website about using drawInRect instead of the CGContext draw methods. It still draws it upside down? I thought using drawInRect would print it right side up with the coordinate system originating at the top left? -(void) drawImage:(UIImage*) image atX:(float) x andY:(float) y withWidth:(float) width andHeight:(float) height onContext:(CGContextRef) context{ UIGraphicsPushContext(context); [image drawInRect:CGRectMake(x, size.height-y-height, width, height)]; UIGraphicsPopContext(); } Notice I'm doing size.height-y-height and if I don't do that it doesn't go where

objective c renderInContext crash on background thread

非 Y 不嫁゛ 提交于 2019-12-03 16:41:01
I have an app in which the screen continuously is capturing in background thread. Here is the code - (UIImage *) captureScreen { UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; CGRect rect = [keyWindow bounds]; UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); [[keyWindow layer] renderInContext:context]; UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIDeviceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation; if ((orientation ==

iPhone CGContext: drawing two lines with two different colors

天涯浪子 提交于 2019-12-03 12:16:33
问题 I am having some troubles using the CGContext with an iPhone app. I am trying to draw several lines with different colors, but all the lines always end up having the color which was used last. I tried several approaches, but haven't been lucky. I set up a small sample project to deal with that issue. This is my code, I use in the drawRect method. I am trying to draw a red and a blue line: - (void)drawRect:(CGRect)rect{ NSLog(@"drawrect!"); CGContextRef bluecontext =