uibezierpath

Reposition CGPath/UIBezierPath in View

瘦欲@ 提交于 2019-12-03 00:04:01
Is it possible to reposition an already drawn CGPath/UIBezierPath on a view? I would like to move or change a path's position then perhaps recall the drawinRect method to just show the drawing again. From your question it sounds like you are drawing the path using Core Graphics inside drawRect: (as compared to using a CAShapeLayer ) so I'll explain the version first. Moving a CGPath You can create a new path by transforming another path. A translation transform moves the transformed object a certain distance in x and y. So using a translation transform you can move your existing path a certain

UIBezierPath draw circle with different strokes

柔情痞子 提交于 2019-12-02 21:00:27
Basically I need to have a circle with stroke in different color, all equal in size. For example, 1/2 is blue and 1/2 is red. Image (sorry for so bad image): How can I draw something like this? There are lots of ways to do it, but one is to just draw two bezier paths, one for each side: - (void)drawRect:(CGRect)rect { UIBezierPath *blueHalf = [UIBezierPath bezierPath]; [blueHalf addArcWithCenter:CGPointMake(100, 100) radius:90.0 startAngle:-M_PI_2 endAngle:M_PI_2 clockwise:YES]; [blueHalf setLineWidth:4.0]; [[UIColor blueColor] setStroke]; [blueHalf stroke]; UIBezierPath *redHalf =

Animated curve line in Swift 3

给你一囗甜甜゛ 提交于 2019-12-02 18:55:47
I want to draw some bezier lines and I want to animate them with a wave effect, Example Do you have some ideas about how I can do this ? Bezier line is it the best method to do it ? I found only 2 libs for this, but they are not really useful for what I need, I try to modify the code of one lib, unfortunately without success https://github.com/yourtion/YXWaveView I found this lib, https://antiguab.github.io/bafluidview/ which does the work, but it written in obj-c, maybe you know something like this in swift You can use a display link , a special kind of timer optimized for screen refresh

Animating between two bezier path shapes

荒凉一梦 提交于 2019-12-02 17:21:31
I found it tricky to animate a UIImageView between two states: its original rectangle frame, and a new shape created with a UIBezierPath . There are many different techniques mentioned, most of which did not work for me. First was the realization that using UIView block animation would not work; evidently one can't perform sublayer animations in an animateWithDuration: block. (see here and here ) That left CAAnimation , with the concrete subclasses like CABasicAnimation . I soon realized that one can't animate from a view that doesn't have a CAShapeLayer to one that does (see here , for

How to animate a human written stroke using Swift/iOS?

我与影子孤独终老i 提交于 2019-12-02 14:18:00
Objective I am attempting to create an animated approximation of human writing, using a UIBezierPath generated from a glyph. I understand and I have read the many UIBezierPath questions which sound similar to mine (but are not the same). My goal is to create an animation that approximates the look of a human performing the writing of characters and letters. Background I've created a playground that I am using to better understand paths for use in animating glyphs as if they were drawn by hand. A couple of concepts in the Apple CAShapeLayer (strokeStart and strokeEnd) really don't seem to

How can I prevent closing Bezier Path

天涯浪子 提交于 2019-12-02 12:09:17
问题 I want to create a Bezier curve, and create a collision boundary for my object. let firstSurfacePoint = CGPoint(x: 30, y: 120) let secondSurfacePoint = CGPoint(x: 20, y: 200) let thirdSurfacePoint = CGPoint(x: 200, y: 300) let center = CGPoint(x: 150, y: 120) let radius: CGFloat = 120.00 let arcWidth: CGFloat = 20.00 let fourthSurfacePoint = CGPoint(x: 240, y: 300) func createCollisionPath(collision: UICollisionBehavior) { let line = UIBezierPath() line.moveToPoint(firstSurfacePoint) line

Eraser the drawing in iOS

柔情痞子 提交于 2019-12-02 11:43:11
I am working on a drawing app, I have a UIBezeirPath, with which I draw in touchesMoved, and convert it to CGPath and then draw on to CGlayer, Here is my code -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { self.currentPath = [[DrawingPath alloc] init]; if(m_eraseButtonClicked) { [self.currentPath setPathColor:[UIColor backgroundColor]]; } else { [self.currentPath setPathColor:self.lineColor]; } CGPathRef cgPath = self.currentPath.path.CGPath; mutablePath = CGPathCreateMutableCopy(cgPath); } - (void)Erase { CGContextRef layerContext = CGLayerGetContext(self.DrawingLayer);

UIView in cell — Can't round right-hand corners

狂风中的少年 提交于 2019-12-02 11:04:56
问题 I have a rectangular UIView object in a static table view cell. I have an outlet to the object and I'm trying to selectively round corners but it will not round corners on the right. Here's what it looks like in the storyboard: The view I want to configure is the pale yellow one. The red view serves no real purpose other than confirming that the other view is not being clipped. There are no constraint issues or errors. Here's how it looks on a 4S: I'm doing the configuration in tableView

SKSpriteNode frame way off

让人想犯罪 __ 提交于 2019-12-02 11:04:40
问题 I am trying to create an open circle from a UIBezierPath and turn that into an SKShapeNode which will later be turned into a SKSpriteNode. I had an problem where I could not figure out how to shrink a Sprite while its line width did not scale down. You can see the solution here: Resize sprite without shrinking contents I ended up fixing some things and creating a new class to implement a custom SKShapeNode with this functionality: class ShrinkableShape: SKShapeNode { let level: Int let

Cocos2d and iOS: Can't understand use of control points using ccBezierConfig

扶醉桌前 提交于 2019-12-02 08:14:10
问题 EDIT: If the question is badly written have a look at the video (3), same link as in the bottom of this page. I am trying to draw a very simple bezier curve using ccBezierConfig and Cocos2D. Reading on Wikipedia I tried to understand a bit controls points and found this image: http://upload.wikimedia.org/wikipedia/commons/thumb/b/bf/Bezier_2_big.png/240px-Bezier_2_big.png If you look on the wikipedia page from which I took the image there is a cool animation. Have a look here. This is the