cashapelayer

CAShapeLayer’s strokeEnd doesn’t animate

筅森魡賤 提交于 2019-12-11 01:52:03
问题 This is the code I’m using to animate my CAShapeLayer : _progressBarLayer.strokeEnd = CGFloat(_progressToDrawForProgress(progress)) let progressAnimation = CABasicAnimation(keyPath: "strokeEnd") progressAnimation.duration = CFTimeInterval(1.0) progressAnimation.fromValue = CGFloat(self.progress) progressAnimation.toValue = _progressBarLayer.strokeEnd progressAnimation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn) _progressBarLayer.addAnimation(progressAnimation,

How to reverse the point order of a CGPath

只谈情不闲聊 提交于 2019-12-10 18:38:19
问题 I want to draw a Circle with Letter punched out of it. to do this, I need to stroke the circle clockwise and the letter counterclockwise. That is all good and well, but when I get the letter path using Core Text I can't figure out how to essentially reverse the path. NOT MIRROR or ROTATE or anything...that is straightforward enough. I want the point stroke order to be counterclockwise. it is actually hilariously difficult. I've had entirely too many visual 'off by one' errors. 回答1: About all

Circle to rectangle transformation animation

僤鯓⒐⒋嵵緔 提交于 2019-12-09 07:16:28
问题 I am very new to iOS and I need to do following animation: Transformation of the circle to rectangle should be smooth, but in above animation it's not very smooth. What I did is create a circle and a rectangle using following code in this tutorial: Circle : class OvalLayer: CAShapeLayer { let animationDuration: CFTimeInterval = 0.3 override init() { super.init() fillColor = Colors.red.CGColor path = ovalPathSmall.CGPath } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has

UIView Layer Mask Animate

寵の児 提交于 2019-12-08 23:58:46
问题 I am trying to animate the mask layer on a UIView. Basically this code displays the image below: let bounds: CGRect = self.manualWBMaskView!.bounds let maskLayer: CAShapeLayer = CAShapeLayer() maskLayer.frame = bounds maskLayer.fillColor = UIColor.blackColor().CGColor let screenWith : CGFloat = UIScreen.mainScreen().bounds.width let roundedRectFrame : CGRect = CGRectMake(self.manualWBMaskView!.bounds.midX - (screenWith/4), self.manualWBMaskView!.bounds.midY - (screenWith/4), screenWith/2,

How to create an Eraser for CALayer.SubLayer Using a CAShapeLayer in Swift

五迷三道 提交于 2019-12-08 13:58:06
问题 I have been looking everywhere for the answer to a question that has been asked a ton of times. I have spent hours looking through SO and Google. There has to be an answer that isn't going to take a mountain moving effort. I am working on a vector drawing app and finally got the drawing and undo-ing functionality working. Now I need an eraser :-o EDIT: Per the great write up from @DonMag I was able to get pretty close to an eraser, but something still isn't quite right. So I am going to try

Draw two parallel line using CAShape Layer

浪子不回头ぞ 提交于 2019-12-08 08:15:12
问题 I am drawing single line by CAShapeLayer *lineShape = nil; CGMutablePathRef linePath = nil; linePath = CGPathCreateMutable(); lineShape = [CAShapeLayer layer]; lineShape.lineWidth = 1.0f; lineShape.lineCap = kCALineJoinMiter; lineShape.strokeColor = [[UIColor redColor] CGColor]; CGPathMoveToPoint(linePath, NULL, x, y); CGPathAddLineToPoint(linePath, NULL, toX, toY); lineShape.path = linePath; CGPathRelease(linePath); [myView.layer addSublayer:lineShape]; i want to draw a parallel line to this

How to disable TouchUpInside Action outside the boundary of button

一笑奈何 提交于 2019-12-08 04:41:11
问题 This is my Xib. I just dragged a UIButton and changed its background color. I created a semi circle layer using this code let circlePath = UIBezierPath.init(arcCenter: CGPointMake(mybutton.bounds.size.width / 4, 0), radius: mybutton.bounds.size.height, startAngle: 0.0, endAngle: CGFloat(M_PI), clockwise: true) let circleShape = CAShapeLayer() circleShape.path = circlePath.CGPath mybutton.layer.mask = circleShape and this is my output. Its perfect as I want it. But the problem is that this

Draw two parallel line using CAShape Layer

余生长醉 提交于 2019-12-07 18:57:18
I am drawing single line by CAShapeLayer *lineShape = nil; CGMutablePathRef linePath = nil; linePath = CGPathCreateMutable(); lineShape = [CAShapeLayer layer]; lineShape.lineWidth = 1.0f; lineShape.lineCap = kCALineJoinMiter; lineShape.strokeColor = [[UIColor redColor] CGColor]; CGPathMoveToPoint(linePath, NULL, x, y); CGPathAddLineToPoint(linePath, NULL, toX, toY); lineShape.path = linePath; CGPathRelease(linePath); [myView.layer addSublayer:lineShape]; i want to draw a parallel line to this line . Any idea or calculation? or is there any code for getting touch point of this particular line .

CAShapeLayer path spring animation not 'overshooting'

白昼怎懂夜的黑 提交于 2019-12-07 09:19:54
问题 I'm experimenting with animating CAShapeLayer paths with CASpringAnimation. The expected result is a 'morphing' between shapes that acts 'springy'. I have a basic code example between a circle and square path as below, however the end result is a spring animation that does not 'overshoot' past the final, larger square path, which is the expected behaviour. My code is: let springAnimation = CASpringAnimation(keyPath: "path") springAnimation.damping = 1 springAnimation.duration =

Drawing a line with Bezierpath using CAShapeLayer object

喜欢而已 提交于 2019-12-06 23:47:41
问题 I am making an image editor which can create different shapes objects like circle, triangle and square which can also be updated or removed. So I have used CAShapeLayer for creating shapes objects. Now I also want to draw a line on image which can also be updated or removed so I have used bezierpath and CAShapeLayer to create the line, it is working fine. BUT now the problem is that when I want to select any existing line it can be selected any where close to line tool because CAShapeLayer