相关疑难解决方法(0)

Bezier路径具有动态宽度变化


我想用动态改变线宽来创建bezier路径.我需要在线的每个部分上花费相同的颜色.因此,较长的线应该更薄.而较短的线应该是大胆的.或者,至少,line应该从开始到结束改变它的宽度.
任何想法如何实现呢?
谢谢.

drawing ios uibezierpath

8
推荐指数
1
解决办法
1763
查看次数

缩放和绘制图像时CGContextStrokePath无法正常工作

我正在根据touchesMoved:方法绘制线条,通常它工作正常.但是当我放大图像并绘制时,先前绘制的线条都会移位并且越来越模糊,最终消失.我已经尝试使用UIPinchGestureRecognizer,只是增加framemyImageView(仅适用于多点触摸事件),但出现问题两种方式.这是绘图的代码:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
 NSArray *allTouches = [touches allObjects];
 int count = [allTouches count];
 if(count==1){//single touch case for drawing line
    UITouch *touch = [touches anyObject];   
    CGPoint currentPoint = [touch locationInView:myImageView];
    UIGraphicsBeginImageContext(myImageView.frame.size);
    [drawImage.image drawInRect:CGRectMake(0, 0, myImageView.frame.size.width, myImageView.frame.size.height)];
    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 2.0);
    CGContextBeginPath(UIGraphicsGetCurrentContext());
    CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
    CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
    CGContextStrokePath(UIGraphicsGetCurrentContext());
    drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    lastPoint = currentPoint;
 }
else{//multi touch case
   // handle pinch/zoom
  }
}
Run Code Online (Sandbox Code Playgroud)

这是在没有缩放的情况下绘制的图像:

在此输入图像描述

这是用放大后用红色箭头表示已经在放大之前绘制的片段(如上图所示)中描述问题的图像.图像模糊不清:

在此输入图像描述

还可以注意到,朝向末端绘制的线的一部分不受影响,并且对于及时拉回的线发生现象.我相信这样做的原因是当我放大/缩小时图像尺寸属性会丢失,这可能会导致模糊和移位,但我不确定!

编辑 - …

iphone core-graphics uiimage pinch ios

6
推荐指数
1
解决办法
1786
查看次数

UIView动画的路径不是线性的

可能重复:
如何沿曲线路径设置视图或图像的移动动画?

我有一个iOS应用程序,我想动画落叶(或几个).我有我的叶子图像,ImageView我从文档中找到了一个简单的动画:

[UIView animateWithDuration:4.0f
                          delay:0
                          options:UIViewAnimationTransitionFlipFromLeft
                          animations:^(void)
                          {
                              leaf1ImageView.frame = CGRectMake(320, 480, leaf1ImageView.frame.size.width,leaf1ImageView.frame.size.height);
                          }
                          completion:NULL];
Run Code Online (Sandbox Code Playgroud)

这将使叶片从其起始位置直线进入右下角.我如何设置动画来跟随路径或曲线如抛物线或正弦曲线,甚至可能旋转图像或视图?这会在动画块中完成吗?提前致谢!

animation uiimageview ios

1
推荐指数
1
解决办法
9324
查看次数