Questions tagged [cgcontextref]
90 questions
1
vote
1 answer
iOS - Can UIGraphicsGetCurrentContext be used outside drawRect?
I want to dynamically change the current CGContextRef according to different user actions? Is this possible or is its modification only possible within drawRect: of a view instance? What happens when I call UIGraphicsGetCurrentContext() outside…

nburk
- 22,409
- 18
- 87
- 132
1
vote
1 answer
Invalid CGContext error in methods called from drawRect
I am trying to write a UIView drawRect: method that calls a helper method to draw a gradient fill with some parameters that I pass along to it:
-(void)drawRect:(CGRect)rect {
CGContextRef ctx = UIGraphicsGetCurrentContext();
/* code to set…

user3513491
- 23
- 5
1
vote
2 answers
CGContextDrawLinearGradient confusion. Need clarification
I am have been experimenting with CGContextDrawLinearGradient and I terribly confused with what start point and end point mean? I thought they mean coordinates on the current CGContext so if I define start point to be 0,0 and end point to be…

noobuntu
- 903
- 1
- 18
- 42
1
vote
2 answers
iOS: reuse CGContextRef?
I need to draw lines based on data received from a server, and I tried to avoid redrawing the whole thing every time I receive a new point, so I thought about:
Re-use CGContextRef and only draw line for new point, or
Use UIMutablePath and add new…

hzxu
- 5,753
- 11
- 60
- 95
1
vote
1 answer
Print NSString in CGContextRef and PDF with a custom font
I'm trying to create a new PDF with custom font.
I load my custom font and I can use it in all app, but when I tried to use it creating my PDF, the System font is printed.
I'm using NSString UIKit Additions.
+(UIFont *)imagoBook:(float)size{
…

xarly
- 2,054
- 4
- 24
- 40
1
vote
0 answers
Find out if CGContext contains a specific Area - iPhone
I am referring to this code - Create masking effect over a view
to produce a scratch card effect. Now, I want to show a particular animation when a particular area lets say (100, 100, 70, 50) is scratched.
Or for that case, I just want to find out…

ScarletWitch
- 522
- 6
- 23
1
vote
1 answer
iOS: Getting CGMutablePath not in drawRect: and Assign it to CAShapeLayer's Path
I have been banging my head on this for hours. I tried to read up and searched for answers. I even tried the "walk-away-and-come-back-to-it-later" approach, it didn't work. I even tried Yoga and meditated! I didn't prevail..
So please enlighten me,…

Unheilig
- 16,196
- 193
- 68
- 98
1
vote
1 answer
Draw a line between two points - How to pass UIView
I am trying to draw a simple line connecting two points. I think i got the right code for that in my drawLine method. No lines appear at all and I am pretty sure it has to do with the View I am calling with and the one I want to draw on. The…

shai4444
- 43
- 9
1
vote
1 answer
CGContextRef draw lines and points,how to clear screen?
I using CGContextRef to draw lines and points in a subview, then i want to redraw. How to clear screen in subview? Thanks.

Roby
- 179
- 2
- 14
1
vote
2 answers
How to clear a CGContextRef?
I experimenting with creating a simple finger-painting application on the ipad. I am able to draw a path to the screen correctly, but I want to have an option that completely clears the screen of all drawn paths. The code I currently have clears the…

Michael
- 6,561
- 5
- 38
- 55
1
vote
1 answer
On iOS, is doing CGContextRelease required?
Because if Instruments is run and Activities Monitor is chosen, the app running on iPhone 4S is using 4.88MB if the contexts are released, and is also 4.88MB if the contexts are not released. So does that mean releasing context is optional? (I…

nonopolarity
- 146,324
- 131
- 460
- 740
1
vote
2 answers
clarification of image properties in objective-c
I'm trying to create randomly generated images for a class I'm writing in objective-c, and was just hoping to get a little clarification as to different image properties and types.
I want to create the following…

user1444872
- 63
- 1
- 4
1
vote
1 answer
Sequentially shift square blocks in UIImage
I am new to Objective-C, but I need to write a fast method, which will divide an UIImage into square blocks of fixed size, and then mix them. I have already implemented it in the following way:
Get UIImage
Represent it as PNG
Convert it to RGBA8…

Kai
- 424
- 5
- 16
1
vote
2 answers
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…

Hitarth
- 1,950
- 3
- 27
- 52
1
vote
1 answer
iPhone:How to use UIGraphicsPushContext
I am making a iPhone app in which a user draw on iPhone screen using his finger
On ViewController1 i am showing a view subclassed from another UIView class
I store all touches moved points in an array
On this view user draws using his finger …

Dinesh Kaushik
- 2,917
- 2
- 23
- 36