Questions tagged [cgcontextref]

90 questions
18
votes
2 answers

Do you need to release CGContextRef in Swift?

I've created a context using CGBitmapContextCreate. Do I need to release it using CGContextRelease? I know the answer is yes in Objective-C, but how about in Swift? Thanks!
user2732722
  • 615
  • 1
  • 10
  • 22
7
votes
4 answers

Stretched UIView background gets cut off during screenshot

So, I am taking a screenshot of a subclassed UIView that I save into the device's photo stream. Problem: The problem is that I use resizableImageWithCapInsets to add a stretched background to my UIView, but this background gets cut off on the right…
Gergely Kovacs
  • 1,045
  • 2
  • 10
  • 28
6
votes
1 answer

How to zoom graph, created with CGContextRef

I am drawing a line graph by using CGContextRef. Can I zoom in zoom out this graph to show lines clearly. I am using this code. CGContextRef context=UIGraphicsGetCurrentContext(); CGContextBeginPath(context); CGMutablePathRef…
Mayank Jain
  • 5,663
  • 7
  • 32
  • 65
6
votes
2 answers

Can I draw shapes like circle,rectangle,line etc outside drawRect method

Can I draw shapes like circle, rectangle, line etc outside drawRect method using CGContextRef contextRef = UIGraphicsGetCurrentContext(); or is it mandatory to use it inside drawRect only. Please help me, let me know how can I draw shapes outside…
Prashant Nikam
  • 2,253
  • 4
  • 17
  • 29
6
votes
2 answers

How can store all points in the CGContextAddArc (CGContextRef) to NSMUtableArray

How can i strore all pixel point in the CGContextAddArc To NSMutableArray.or CGContextRef to NSMutable Array static inline float radians(double degrees) { return degrees * PI / 180; } - (void)drawRect:(CGRect)rect { CGContextRef context =…
Musthafa
  • 862
  • 3
  • 12
  • 27
5
votes
3 answers

Crash whille Converting NSURL to CFURL

I want to create pdf in document directory and want to give page numbers so I need CGPDFDocumentRef object. let fileName: NSString = "test.pdf" let path:NSArray = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true) let…
Anil Kukadeja
  • 1,348
  • 1
  • 14
  • 27
5
votes
3 answers

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

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 { …
Hitarth
  • 1,950
  • 3
  • 27
  • 52
3
votes
2 answers

UIColor and Graphics Context

I have a custom UIView which draws a path like so - (void)drawRect:(CGRect)rect{ [[UIColor blackColor] setStroke]; CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextSetFillColor(ctx, CGColorGetComponents(self.color)); …
tmpz
  • 368
  • 3
  • 12
3
votes
1 answer

How to clear circle in CGContext in iOS

I want create image using CGcontext. This is simple image with white or black background. also I want to add transperent part which is in circle ( check attached image). I know how to do this in rect. But i want to make it circle. Please anyone help…
technerd
  • 14,144
  • 10
  • 61
  • 92
3
votes
4 answers

Use CGContextClip to clip a circle with image

Have a imageViewA (frame{0,0,320,200}) in my app, and I want to clip a circle with the imageViewA's center, radius=50, and draw into another imageViewB (frame{0,0,100,100}); the original image effect like this : and use below code to…
Roby
  • 179
  • 2
  • 14
3
votes
2 answers

How to move the image on the CGContextRef

An image has been drawn on the CGContextRef: CGContextDrawImage(context, CGRectMake(0, 0, width, height), image); In another function, I want to move the image to the rect like CGRectMake(100, 100, width, height); How can I do? void…
KChen
  • 1,922
  • 14
  • 15
3
votes
1 answer

Replace specific color in CGBitmapContext

How can I replace specific color(RGB value) in CGBitmapContext that has already drawn? Is there any easy way? Thanks in advance.
Jun
  • 3,422
  • 3
  • 28
  • 58
2
votes
2 answers

Masking an image using CGLayerRef and CGContextDrawLayerInRect

I want to mask an image by another image using CGLayerRef in off-screen rendering since it's suitable for high-quality rendering as it's mentioned in documentation Core Graphics Layer Drawing : CGLayer objects allow your application to use…
Reza.Ab
  • 1,195
  • 1
  • 11
  • 21
2
votes
1 answer

CGContext AND CGContextRef the same in Swift? How does this work?

I was porting some ObjectiveC custom UIView subclasses to Swift this morning. Wanting to make it more "object oriented", I was following the example of extending CGContext with methods. E.g. extension CGContext { func fillColor(color:UIColor)…
Travis Griggs
  • 21,522
  • 19
  • 91
  • 167
2
votes
1 answer

cropping an area CGRect from UIGraphicsImageContext

I have a CGPath shaped like an arrow that I am drawing in the CGContext of my current view. I would like to generate a miniature version (thumbnail) of the arrow to add it as an Image to a UITableView showing all selected arrows. I am succeeding to…
user1612877
  • 391
  • 1
  • 5
  • 19
1
2 3 4 5 6