Tag: uibezierpath

UIbezierpath在可缩放视图中

我在可缩放的UIView(pdf阅读器的绘图层)中绘制了bezierpaths。 当我放大文档UIView也放大,但是所有的图纸和线条看起来更像素化。 有没有办法渲染这些path没有太多的像素化? 它假设贝塞尔path是基于vector的… 提前致谢!

正弦CAShapeLayer作为CALayer的掩码

我试图实现下一个好奇的事情:我有几个点,我想把他们与正弦波 下一个方法返回用于绘制的点arrays: – (NSArray *)plotPointsBetweenPoint:(CGPoint)pointA andPoint:(CGPoint)pointB { double H = fabs(pointB.y – pointA.y); double L = fabs(pointB.x – pointA.x); NSInteger granularity = 40; NSMutableArray *array = [NSMutableArray arrayWithCapacity:granularity + 1]; for (int i = 0; i <= granularity; ++i) { CGFloat x = M_PI*(float)i/(granularity); CGFloat y = -cosf(x); CGFloat multiplier = pointA.y > pointB.y ? […]

UIBezierPath圆边?

我画了一些线条,我注意到,当边缘达到一定的angular度,它会产生一个像这样的尖锐的边缘: 我想要它画什么: 我该怎么做呢? 我已经浏览了文件,但我似乎没有find任何即时消息寻找。 或者有没有办法把这个自动边缘生成关掉?

在Swift中将球拖过圆圈path

我做了一个圆形path,圆形path的中心位于视图的中间。 然后,我做了一个只能在圆形path上移动的球(至less这是我想要的): 我做了一个移动球的function,只要我拖动它(仅在圆形path上),但由于某种原因,每当我拖动它时,它就会变得疯狂,并且不会随着我的移动而移动。 这是我的代码到目前为止: class ViewController: UIViewController { var midViewX = CGFloat() var midViewY = CGFloat() var circlePath2 = UIBezierPath() var shapeLayer2 = CAShapeLayer() override func viewDidLoad() { super.viewDidLoad() midViewX = view.frame.midX midViewY = view.frame.midY // Do any additional setup after loading the view, typically from a nib. let circlePath = UIBezierPath(arcCenter: CGPoint(x: midViewX,y: midViewY), […]

iOS:逆UIBezierPath(bezierPathWithOvalInRect)

我有一个圆形对象的JPG图像矩形,并希望使圆形对象的透明度… (在这个例子中删除红色区域) 在这个iOS的帮助下, 使UIImage透明和“UIBezierPath bezierPathWithOvalInRect”的一部分,我已经取得了一些成功,但是这使得我的对象周围的道路,我需要倒过来,使外部而不是内部path透明.. 我不知道我必须改变我的代码才能得到正确的结果.. 这是我的代码: //BezierPath UIBezierPath *bezierPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, 100, 100)]; // Create an image context containing the original UIImage. UIGraphicsBeginImageContext(_imgTemp.image.size); [_imgTemp.image drawAtPoint:CGPointZero]; // Clip to the bezier path and clear that portion of the image. CGContextRef context = UIGraphicsGetCurrentContext(); CGContextAddPath(context,bezierPath.CGPath); CGContextClip(context); CGContextClearRect(context,CGRectMake(0,0,self._imgTemp.image.size.width,self._imgTemp.image.size.height)); // Build a new UIImage from the […]

在UIView中的BezierPath旋转

我正在绘制一个BezierPath on Touch事件。 现在我必须使用手势方法在相同的位置上旋转Bezierpath。 但问题是,轮换之后它的地位就变了。 它看起来像下面的图像..我怎样才能解决这个问题? 上图是原始图像。 与我分享你的想法..在此先感谢

将图像剪裁成覆盖图的形状 – iOS

我使用pickerController的视图和uinavigationcontrollerdelegate添加覆盖,如下所示。 -(void)navigationController:(UINavigationController *)navigationController didShowViewController: (UIViewController *)viewController animated:(BOOL)animated{ if ([navigationController.viewControllers count] == 3) { CGFloat screenHeight = [[UIScreen mainScreen] bounds].size.height; UIView *plCropOverlay = [[[viewController.view.subviews objectAtIndex:1]subviews] objectAtIndex:0]; plCropOverlay.hidden = YES; int position = 0; if (screenHeight == 568) { position = 124; } else { position = 80; } CAShapeLayer *circleLayer = [CAShapeLayer layer]; UIBezierPath *path2 = […]

如何获得一个UIBezierPath的反向path

self.myPath=[UIBezierPath bezierPathWithArcCenter:center radius:200 startAngle:0 endAngle:180 clockwise:YES]; (这一点我可以起来运行一些谷歌search帮助..) 我有这条路 现在我想填补这个path的相反,所以留下这个部分,填补一切。 任何人都可以帮我编码。 我没有太多的信息。 >问题 在使用Cemal之后它显示的区域以前它只显示了一个有红色中风的圈子。 >新编辑 – (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor whiteColor]; self.punchedOutPath = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(50, 50, 400, 400)]; self.fillColor = [UIColor redColor]; self.alpha = 0.8; } return self; } – (void)drawRect:(CGRect)rect { [[self fillColor] set]; UIRectFill(rect); CGContextRef ctx […]

closures使用closePath函数的贝塞尔path和手动closures之间有什么区别?

我正在尝试使用UIBezierPath做一个矩形。 我采取了两种不同的方式来绘制它。 另外,我增加了行程宽度为25像素。 第一种方法:使用closePath UIBezierPath *bpath = [UIBezierPath bezierPath]; [bpath moveToPoint:CGPointMake(x, y)]; [bpath addLineToPoint:CGPointMake(x + w, y)]; [bpath addLineToPoint:CGPointMake(x + w, y + h)]; [bpath addLineToPoint:CGPointMake(x, y + h)]; [bpath closePath]; 输出: 第二种方法:手动closurespath UIBezierPath *bpath = [UIBezierPath bezierPath]; [bpath moveToPoint:CGPointMake(x, y)]; [bpath addLineToPoint:CGPointMake(x + w, y)]; [bpath addLineToPoint:CGPointMake(x + w, y + h)]; [bpath addLineToPoint:CGPointMake(x, […]

伸展的UIBezierPath线?

我想用我的手指画出一条直线,根据我离原点的距离来自动resize。 所以如果我在中间触摸屏幕并且滑动我的手指,当我的手指在屏幕上移动时,一条线似乎“伸展”并围绕orgin点旋转。 当我抬起我的手指。 目的地点应最终确定并创build一条线。 我可以将手指拖过屏幕,然后在屏幕上“绘制”,但这不是我想要做的。 我认为UIBeizerPath moveToPoint会帮助,但它只是弄乱了事情。 我究竟做错了什么? – (id)initWithFrame:(CGRect)frame { //default line properties myPath=[[UIBezierPath alloc]init]; myPath.lineCapStyle=kCGLineCapRound; myPath.miterLimit=0; myPath.lineWidth=lineWidth; brushPattern=[UIColor blackColor]; } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { CGPoint curPoint = [[touches anyObject] locationInView:self]; lastPoint = curPoint; [myPath moveToPoint:lastPoint]; [pathArray addObject:myPath]; [self setNeedsDisplay]; } -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ CGPoint curPoint = [[touches anyObject] locationInView:self]; myPath.lineWidth=lineWidth; brushPattern=[UIColor […]