core-graphics

How can I combine CGPathCreateCopyByDashingPath() and CGPathCreateCopyByStrokingPath() to stroke a dashed CGPath on OS X?

僤鯓⒐⒋嵵緔 提交于 2019-12-12 03:24:11
问题 Core Graphics has two functions, CGPathCreateCopyByDashingPath() and CGPathCreateCopyByStrokingPath() , that both take a CGPath that you want to stroke and convert it into its equivalent fill. I need to do this so I can, for example, stroke a line with a gradient: call CGPathCreateCopyByStrokingPath() , load the path into the CGContext, call CGContextClip() , and then draw the gradient. However, CGPathCreateCopyByStrokingPath() accepts line stroking parameters like line cap, line join, etc.,

Keeping track of changes in a UIView

随声附和 提交于 2019-12-12 03:23:29
问题 I have a subclassed UIView (currentMapView) that draws a map of several states using a series of CGMutablePaths pulled from an XML file. When the user taps on a state the fill color changes from green to purple. Right now I figure out which state was tapped on the fly using CGPathContainsPoint to report back which path was tapped and I then set the fill color of that path and reload the view using setNeedsDisplay. The problem I have is that I need to re-use currentMapView several times

BlurView below a button with fading edges

南楼画角 提交于 2019-12-12 03:06:57
问题 I created a button on top of my mapView. In order to make that Button more visible I added a blur view below that button. I don't like the sharp edges of my blur view. How do I make the blur fade out slowly transitioning into the mapView? EDIT: To be more specific. I mean a fading blurred gradient with round corners. 回答1: I think this can help you, first you need subclass your button and add this code in drawRect and replace UIColor.blueColor().CGColor by yourColor.CGColor class

iOS swipe filters over static image

南笙酒味 提交于 2019-12-12 02:39:12
问题 I'm looking for a way to swipe image filters over top of a still image. Mainly the base image stays in place, and the filters slide in over top when you swipe left or right. Right now I have a base UIImageView and a Collection View over top of it which in theory would hold the filters (texture and gradient images). I've read that UIImageViews and UIViews can't be live composited on top of each other, and that you must make the image before displaying it. So I can pre-make the image beforehand

How to make equal space between texts in the circular menu?

烈酒焚心 提交于 2019-12-12 01:53:26
问题 I am creating a circular slider menu, I am using coregraphics to draw the control UI, Here I am trying to draw words on the circumference of a circle. But i cant able to make the spaces equally. Here is my code and output. Please help me to give equal spaces between each word. In drawRect float angleStep = 2 * M_PI / [menuArray count]; float angle = degreesToRadians(90); textRadius = textRadius - 12; for (NSString* text in`enter code here` titleArray) { [self drawStringAtContext:ctx string

Coregraphics causing big lag on iPad?

旧巷老猫 提交于 2019-12-12 01:48:49
问题 UIGraphicsBeginImageContext(self.view.bounds.size); [currentStrokeImageView.image drawInRect:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)]; CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound); CGContextSetBlendMode(UIGraphicsGetCurrentContext(), kCGBlendModeNormal); CGContextSetLineWidth(UIGraphicsGetCurrentContext(), dWidth); CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), r, g, b, 1.0f); CGContextBeginPath(UIGraphicsGetCurrentContext(

Create a radial gradient mask to create a hole in the picture

本秂侑毒 提交于 2019-12-12 01:43:54
问题 I want to create a radial gradient mask to create a hole in the picture, so that you can see through the picture. I created an overlaying image with a hole and the image beneath is visible, like below: I am able to create this image using CGImageMaskCreate() successfully. But due to the unusual behaviour of CGImageMaskCreate() in iOS 10.0, I am looking for another solutions. One such solution is to create image mask using the UIView's maskView property. I am able to write the code for

iOS: Animate item twice

余生长醉 提交于 2019-12-12 01:10:04
问题 Just starting out with core graphics. Playing with a simple button and label. I want this label to rotate 180 degrees on each click of the button. It only animates on the first click (the console does write "DONE" on each click, however) - (IBAction)btnTest:(id)sender { [UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{ lblTest.layer.transform = CATransform3DMakeRotation(M_PI,0.0,1.0,0.0); }completion:^(BOOL finished) { if(finished) NSLog(@"DONE"); }]

Mutlitouch drawing in iOS

Deadly 提交于 2019-12-12 01:05:51
问题 I am working with drawing project, and it is quite working well, the only problem is that, it works only with single touch.I want to do multitouch drawing, so that if user draws with his two fingers, then it should draw them Below is my code for single touch drawing -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; //LocationInView returns the current location of the reciever in coordinate system of the given View. m_previousPoint1 =

Hotkey when no assistance enabled CGEventTap

匆匆过客 提交于 2019-12-12 00:15:35
问题 I had used addLocal and it would work in my application, but I want to watch globally so i tried addGlobalMonitorForEventsMatchingMask:handler: but NSEventKeyDown is not getting triggered at all. Apparently it needs assistive permission enabled. I am able to watch NSScrollWheel events globally. Which is interesting. Before I put a bunch of time into and come to same roadblock I was hoping to ask first, would using CGEventTap to monitor key events work globally without assitive turned on?