cgcontext

How to draw a UILabel with a different blend mode in draw(_ rect: CGRect) in Swift

跟風遠走 提交于 2019-12-05 21:07:30
So I have a UILabel that is being drawn on top of a gradient image (that is a UIImageView ). It looks sorta like this: I'm trying to change the blendMode of the graphics context in the UILabel 's draw(_ rect: CGRect) function so that it draws the label but blended with the background with a softLight blending mode. Here is what I want it to look like: Here is the code I have in the draw(_ rect: CGRect) function: override func draw(_ rect: CGRect) { // Drawing code if let context = UIGraphicsGetCurrentContext() { context.setBlendMode(.softLight) self.textColor.set() self.drawText(in: rect) } }

How to use NSUndoManager with a UIImageView or CGContext

痞子三分冷 提交于 2019-12-05 18:23:58
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 I write graphics software for the iPhone ( http://www.layersforiphone.com/ ) and I spent a while trying to figure this out

Static background for CGContext

青春壹個敷衍的年華 提交于 2019-12-05 17:30:40
this is my first question here, so hello everyone. I have spent some time now wrapping my mind around the following problem and could not come up with a solution. I'd be happy if someone could point me in the right direction. I'm using CGContext to draw various layers of graphical representations of live data which should be refreshed at a reasonable framerate of at least 50fps. I want to use a static image as a background. Re-drawing this image using the context for every cycle significantly slows down the frame-rate. I thought about just using UIImageView to display the image once. The

Draw Line using CGContext

拟墨画扇 提交于 2019-12-05 13:56:48
问题 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

How to create embossed or shadow effects using Core Graphics (for finger paint)

筅森魡賤 提交于 2019-12-05 11:42:53
I have issue to implement "Emboss/Shadow effects" in my drawing. Finger paint functionality is currently working fine with my custom UIView and below is my drawRect method code: Edit code with all methods : - (void)drawRect:(CGRect)rect { CGPoint mid1 = midPoint(previousPoint1, previousPoint2); CGPoint mid2 = midPoint(currentPoint, previousPoint1); CGContextRef context = UIGraphicsGetCurrentContext(); [self.layer renderInContext:context]; CGContextMoveToPoint(context, mid1.x, mid1.y); CGContextAddQuadCurveToPoint(context, previousPoint1.x, previousPoint1.y, mid2.x, mid2.y); CGContextSetLineCap

Remove alpha channel from UIImage

瘦欲@ 提交于 2019-12-05 09:59:36
I use the following method to get a decompressed uiimage from file system. However the UIImageView is colored as red when I turn on the color blended layer, even though the UIImageView is set to Opaque. The images on file system don't have alpha channel. I tried set CGContextSetAlpha(bitmapContext, 1), but still has blended layer. Anyone know how to remove alpha channel when using CGContextDrawImage? - (UIImage *)decompressedImage { CGImageRef imageRef = self.CGImage; CGRect rect = CGRectMake(0.f, 0.f, CGImageGetWidth(imageRef), CGImageGetHeight(imageRef)); CGContextRef bitmapContext =

iPhone clear CGContext

你说的曾经没有我的故事 提交于 2019-12-05 09:16:51
I create a circle with a nice shadow with this code (I use MonoTouch.net for iPhone, Objective-C answers are fine of course) UIGraphics.PushContext (ctx); SizeF shadowSize = new SizeF (0f, -3f); ctx.SetRGBFillColor (194f / 255f, 212f / 255f, 238f / 255f, 1f); ctx.SetAllowsAntialiasing (true); ctx.SetShadowWithColor (shadowSize, 20, new CGColor (0.9f, 0.7f)); RectangleF area = new RectangleF (35f, 15f, 210f, 210f); ctx.FillEllipseInRect (area); UIGraphics.PopContext (); Then I want to add to it an arc and lines. When I do, the colors and shadow etc seem to stick around? How do I 'start fresh'

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

你离开我真会死。 提交于 2019-12-05 02:29:21
问题 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

using UIImage drawInRect still renders it upside down

谁说我不能喝 提交于 2019-12-05 02:09:07
问题 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)];

objective c renderInContext crash on background thread

与世无争的帅哥 提交于 2019-12-05 01:40:37
问题 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 =