Tag: 绘制代码

dynamic改变基于scrollView的位置

我有一个“U”形UIBezierPath ,我用myImage.layer作为animation的path 。 我也有一个scrollView。 我的目标是有一个自定义的“拉到刷新”animation。 我遇到的问题是,我希望我的myImage.layer根据scrollView滚动多less进行更新。 当scrollView被拉下时, myImage.layer沿着一个“U”形pathanimation。 这是我作为UIBezierPath创build的代码中的path 。 这是我如何计算scrollView被拉下多远: func scrollViewDidScroll(scrollView: UIScrollView) { let offsetY = CGFloat(max(-(scrollView.contentOffset.y + scrollView.contentInset.top), 0.0)) self.progress = min(max(offsetY / frame.size.height, 0.0), 1.0) if !isRefreshing { redrawFromProgress(self.progress) } } 这是dynamic更新位置的function(它不工作): func redrawFromProgress(progress: CGFloat) { // PROBLEM: This is not correct. Only the `x` position is dynamic based on scrollView […]

animation贝塞尔曲线点

我正在试图使用Paintcode(伟大的应用程序,顺便说一句)制作一个贝塞尔曲线,并在“drawRect”方法中绘制自定义的UIView。 绘图工作正常,但我想要在贝塞尔曲线单一点的animation。 这是我的非工作方法: -(void)animateFlame{ NSLog(@"Animating"); // Create the starting path. Your curved line. //UIBezierPath * startPath; // Create the end path. Your straight line. //UIBezierPath * endPath = [self generateFlame]; //[endPath moveToPoint: CGPointMake(167.47, 214)]; int displacementX = (((int)arc4random()%50))-25; int displacementY = (((int)arc4random()%30))-15; NSLog(@"%i %i",displacementX,displacementY); UIBezierPath* theBezierPath = [UIBezierPath bezierPath]; [theBezierPath moveToPoint: CGPointMake(167.47, 214)]; [theBezierPath addCurveToPoint: […]