Tag: cgcontext

Merging two images of different size with rotate and zoom

I’m facing the following problem : I have to merge two images bottomImg and topImg to create a new image C as a result of the merging. I already know how to merge two images but in this case my goal is a little bit different. top image may be zoomed and rotated. I have […]

kCGTextStroke's Fill and Stroke aren't positioned correctly

So I’m using the code below to apply a stroke (and fill) to text in a UILabel, and it’s coming out like the image below. The stroke is heavier on one side than the other (look at the top of the letters compared to the bottom, and the right compared to the left. The period […]

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

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 […]

Crazy rounded rect UIBezierPath behavior on iOS 7. What is the deal?

The simple UIView below draws a rounded rectangle. When I pass a corner radius of 65 or below it rounds correctly, but 66 and above and it generates a perfect circle! What is going on here? It should only show a circle when the corner radius is equal to 1/2 the frame width, but it […]

How to erase part of an image as the user touches it

My big picture goal is to have a grey field over an image, and then as the user rubs on that grey field, it reveals the image underneath. Basically like a lottery scratcher card. I’ve done a bunch of searching through the docs, as well as this site, but can’t find the solution. The following […]

Drawing around CGContextRef to remove pixelation

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 […]

How to erase finger paint on Custom UIView in iPhone

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; […]

Using CGContext to display a sprite sheet iPhone

So I have a spritesheet in png format, and have already worked out the coordinates for what I want to display. I’m trying to create a method that will return a UIImage when passed the location information on the spritesheet. I’m just not sure how to use the CGContext stuff along with the the coordinates […]

Create new UIImage by adding shadow to existing UIImage

I’ve taken a look at this question: UIImage Shadow Trouble But the accepted answer didn’t work for me. What I’m trying to do is take a UIImage and add a shadow to it, then return a whole new UIImage, shadow and all. This is what I’m trying: – (UIImage*)imageWithShadow { CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef […]

How can I use Core Graphics to draw a circle at my touch location?

New programmer here. I am having issues trying to use Core Graphics to draw a stroked arc around my touch location. I have the method to draw the circle working fine, and I have tested and am registering touches when I tap the screen, but when I try to call the method to draw the […]