core-graphics

Creating a union of 2 bezier paths

你说的曾经没有我的故事 提交于 2019-12-09 14:21:45
问题 I have two bezier paths that i'd like to combine to form a union, so that I can stroke the entire outer shape. In my case, it's a speech bubble with a tail, so although it's not a complex shape it would actually be quite hard to create it using one single path. There doesn't appear to be a Core Graphics API for creating unions. Am I wrong? If I'm not, does anyone know of a library that can handle this? I've search GitHub to no avail. 回答1: UIBezierPath does that if you are working with closed

Do I need to release the context returned from UIGraphicsGetCurrentContext()?

落花浮王杯 提交于 2019-12-09 14:04:13
问题 I am using CGContextRef . UIGraphicsBeginImageContext(self.drawImage.frame.size); CGContextRef context=UIGraphicsGetCurrentContext(); CGContextSetRGBStrokeColor(context,0.0f,0.0f,0.0f,1.0f); UIGraphicsEndImageContext(); CGContextRelease(context); Do I need to call CGContextRelease(Context); in the above one. 回答1: No. See The Create Rule vs. The Get Rule: The Create Rule Core Foundation functions have names that indicate when you own a returned object: Object-creation functions that have

Rounded rect with Gradient color

为君一笑 提交于 2019-12-09 12:36:48
问题 I have not really done much programming with Core Graphics. And I tend to stick with QuartzCore now that it does a lot of what I need through the layer property :) However, I have a UIView, which is currently gradient. I'd like to add rounded corners to this UIView and the layer property does not do this when I draw the gradient: - (void)drawRect:(CGRect)rect { CGContextRef currentContext = UIGraphicsGetCurrentContext(); CGGradientRef glossGradient; CGColorSpaceRef rgbColorspace; size_t num

Can't draw in UITableViewCell's drawRect

依然范特西╮ 提交于 2019-12-09 11:50:15
问题 I'm having trouble drawing in the drawRect method of my custom UITableViewCell. Here is the code I am using - (void)drawRect:(CGRect)rect { CGContextRef ctx = UIGraphicsGetCurrentContext(); CGPoint origin = _faceView.frame.origin; CGFloat width = _faceView.frame.size.width; CGFloat height = _faceView.frame.size.height; CGFloat border = 2.0f; CGPoint startPt = CGPointMake(origin.x + width/2, self.frame.size.height); CGContextBeginPath(ctx); CGContextMoveToPoint(ctx, startPt.x, startPt.y);

Changing cornerRadius using Core Animation

只愿长相守 提交于 2019-12-09 11:10:39
问题 I am trying to change the corner radius of a button (OpenNoteVisible.layer) in the following way: CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"cornerRadius"]; animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; animation.fromValue = [NSNumber numberWithFloat:10.0f]; animation.toValue = [NSNumber numberWithFloat:0.0f]; animation.duration = 1.0; [animation.layer setCornerRadius:140.0]; [OpenNoteVisible.layer addAnimation

UIGraphicsBeginImageContext vs CGBitmapContextCreate on iOS

烈酒焚心 提交于 2019-12-09 08:28:30
问题 This may be a really stupid question, but can someone tell me the difference between creating a CGContextRef using UIGraphicsBeginImageContext and using CGBitmapContextCreate for drawing to images? Especially now since UIKit drawing is thread safe I was wondering if there was any reason to use CGBitmapContextCreate over UIGraphicsBeginImageContext. 回答1: According to Apple's UIKit Function Reference, which carries the cover date of the 15th November 2010, UIGraphicsBeginImageContext and

how to create a path using coregraphics?

点点圈 提交于 2019-12-09 07:18:18
问题 i want to create a path.something like i touch the screen and draw line in touchmove event.when line intersect from starting point.fill that path using any colour. now see in the image i've drawn a line.i just want to detect if line intersects again to start point.then fill that path with my own desired color.also i m using core graphics to draw line but it's very slow on real device.could you tell me a way to improve speed? 回答1: Header: #import <UIKit/UIKit.h> @interface myView : UIView {

Creating an animated GIF in Cocoa - defining frame type

拜拜、爱过 提交于 2019-12-09 06:46:27
问题 I've been able to adapt some code found on SO to produce an animated GIF from the "screenshots" of my view, but the results are unpredictable. GIF frames are sometimes full images, full frames ("replace" mode, as GIMP marks it), other times are just a "diff" from previous layer ("combine" mode). From what I've seen, when there are fewer and/or smaller frames involved, the CG writes the GIF in "combine" mode, but failing to get the colors right. Actually, the moving parts are colored correctly

In iOS Development, using Core Graphics and/or Quartz 2D, how can I draw a circle filled with a gradient in such a manner that it looks like a sphere?

三世轮回 提交于 2019-12-09 06:15:15
问题 So far I have looked at using CGContextDrawLinearGradient() and CGContextDrawRadialGradient(), however, with the former I can't figure out how to make the gradient look like a sphere, and with the latter, I can't figure out how to make the gradient into the shape of a sphere, because every time I try, it turns out in the shape of the full cylinder instead of only a sphere. The code I am using to current draw a 2D circle is shown below. I would like to use a gradient or any other method

In iOS, how can you programmatically fill out a pdf form field?

拜拜、爱过 提交于 2019-12-09 05:50:42
问题 I need to take an existing pdf file and programmatically fill in a list of form fields with text and then save the pdf without ever displaying it to the user. For instance, if the pdf file contains fields named "LastName", and "FirstName" I would like to set the value of "FirstName" to "Louis" and then save the file. I've been searching for a long time and can't find any guidance on even where to start since the iOS documentation (and most of the questions on here) seem geared towards