core-graphics

CATiledLayer drawLayer:inContext: crashing when the view is deallocated while the image to draw is being retrieved

≡放荡痞女 提交于 2019-12-05 12:29:13
My app crashes when my ViewController gets deallocated while my CATiledLayer is retrieving the image to draw in a background thread. I get a message -[MyViewController respondsToSelector:]: message sent to deallocated instance 0x8f58e00 and the debugger shows 0 ___forwarding___ 1 __forwarding_prep_0__ 2 -[CATiledLayer(CATiledLayerPrivate) canDrawRect:levelOfDetail:] 3 tiled_layer_render 4 CAImageProviderThread 5 CAImageProviderBackgroundThread 6 CA::DispatchGroup::thread 7 thread_fun 8 _pthread_start Now, I do want to release that certain instance of MyViewController because I don't need it

Is there an iOS equivalent of appendBezierPathWithArcWithCenter

 ̄綄美尐妖づ 提交于 2019-12-05 12:10:35
I'm trying to draw a quarter circle in iOS. In Mac OS, it seems you can use appendBezierPathWithArcWithCenter but this doesn't seem to work in iOS. Does anyone know how to simply draw a quarter circle in iOS? Thanks There are two iOS equivalents, one for UIBezierPath and one for CGPath : UIBezierPath equivalent UIBezierPath *path = [UIBezierPath bezierPath]; [path addArcWithCenter:centerPoint radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES]; CGPath equivalent CGMutablePathRef path = CGPathCreateMutable(); CGPathAddArc(path, NULL, centerPoint.x, centerPoint.y, radius,

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

iOS - CoreImage - Add an effect to partial of image

梦想的初衷 提交于 2019-12-05 11:32:01
I just have a look on CoreImage framework on iOS 5, found that it's easy to add an effect to whole image. I wonder if possible to add an effect on special part of image (a rectangle). for example add gray scale effect on partial of image/ I look forward to your help. Thanks, Huy Felix Watch session 510 from the WWDC 2012 videos. They present a technique how to apply a mask to a CIImage . You need to learn how to chain the filters together. In particular take a look at: CICrop , CILinearGradient , CIRadialGradient (could be used to create the mask) CISourceOverCompositing (put mask images

CGAffineTransformMakeRotation around external point

两盒软妹~` 提交于 2019-12-05 11:09:36
are there a way for rotate UIImage around external point using CGAffineTranformMAkeRotation? tnx a lot! Here is a function that uses the same format as the CoreGraphics CGAffineTransform API format. This works exactly how other "RotateAt()" APIs should work. The operation represents the equivalent of the following specification: translate(pt.x, pt.y); rotate(angle); translate(-pt.x, -pt.y); CGAffineTransform CGAffineTransformMakeRotationAt(CGFloat angle, CGPoint pt){ const CGFloat fx = pt.x, fy = pt.y, fcos = cos(angle), fsin = sin(angle); return CGAffineTransformMake(fcos, fsin, -fsin, fcos,

iOS: Inverse UIBezierPath (bezierPathWithOvalInRect)

北城以北 提交于 2019-12-05 10:59:57
问题 I have an jpg Image with a round object in a rect and want to make the envoirement of the round object transparent... (Remove red area in this example) With the help of this iOS make part of an UIImage transparent and "UIBezierPath bezierPathWithOvalInRect" i've got a little success, but this make a path around my object, and I need to invert it, to make the outside and not the inside of the path transparent.. Im not shure where I have to change my code to get the right result.. Here is my

Is it possible to make UILabel with non-English characters green when Color Blended Layer is enabled?

扶醉桌前 提交于 2019-12-05 08:28:52
I have a table view with custom cells and I try to optimize it by making all subviews inside the cells in green color when Color Blended Layer is checked in the simulator. When the background of an UILabel in the cell is set to white: let title = UILabel() contentView.addSubview(title) title.background = UIColor.whiteColor() title.text = "Hi, how are you?" This UILabel subview will become green color in the simulator, which is good. However, if I change the text to some Chinese: title.text = "你好" The UILabel subview will become red. This SO post provides some explanation about the situation.

How to draw CGGradient with specific color?

最后都变了- 提交于 2019-12-05 08:08:11
问题 I have this Objective-C code that I found somewhere. Honestly, I don't understand a single thing that is going on down there. I'm not at all familiar with Core Graphics. The code below represents the image on the left. What I want is a similar color gradient to the image on the right (desired color has RGB of 12, 138, 255). Where on earth do I change this code to get the desired result? - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGSize titleSize =

Clipping a CGGradient to a CGPath

倖福魔咒の 提交于 2019-12-05 07:12:28
问题 I've been banging my head against the wall for a long while trying to figure out why this is not working. Basically, I am trying to plot a graph (chart) with CGPath and then use that to clip a gradient. The end effect should be like the Stocks app which comes with the iPhone. The gradient and the path draw fine separately as two layered (unclipped) elements. But if I comment out the CGContextDrawPath, neither the line nor the gradient draw to the screen. Here's my drawRect code: CGContextRef

Resetting the origin of a transformed UIView descends into craziness

喜夏-厌秋 提交于 2019-12-05 05:42:40
问题 I rotate/scale a UIVIew using [UIView transform:] and this works well. However, as soon as I change the view's frame origin the contents of the view begins to scale 'weirdly' even though I am not performing any further CGAffineTransforms. Why does this occur? How can I prevent it? Update 1: The docs suggest that the frame is invalid after a transform. Can I move the view via it's 'center' property instead? Update 2: Setting the views center did allow me to translate the view successfully