uibezierpath

How to rotate UIBezierPath around center of its own bounds?

徘徊边缘 提交于 2019-12-04 01:49:08
问题 Lets say we have a UIBezierPath... the bounds of which are perfectly square... like this: func getExponentPath(rotate180: Bool) -> UIBezierPath { // establish unit of measure (grid) based on this containing view's bounds... (not to be confused with this bezierpath's bounds) let G = bounds.width / 5 let exponentPath = UIBezierPath() let sstartPoint = CGPoint(x:(3.8)*G,y:(1.2)*G) exponentPath.move(to: sstartPoint) exponentPath.addLine(to: CGPoint(x:(5)*G,y:(1.2)*G)) exponentPath.addLine(to:

start and end angle of UIBezierPath?

ⅰ亾dé卋堺 提交于 2019-12-04 01:33:28
I have coded as below for half circle in iOS using UIBezierPath and CAShapeLayer . clockWiseLayer = [[CAShapeLayer alloc] init]; CGFloat startAngle = -M_PI_2; CGFloat endAngle = M_PI + M_PI_2; CGFloat width = CGRectGetWidth(imageView.frame)/2.0f + 30; CGFloat height = CGRectGetHeight(imageView.frame)/2.0f +50; CGPoint centerPoint = CGPointMake(width, height); float radius = CGRectGetWidth(imageView.frame)/2+10; clockWiseLayer.path = [UIBezierPath bezierPathWithArcCenter:centerPoint radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES].CGPath; clockWiseLayer.fillColor = [UIColor

Custom Button frame doesn't look as good as Round Rect UIButton

雨燕双飞 提交于 2019-12-04 00:28:24
问题 I'm trying to draw a custom button frame as follows: UIBezierPath *stroke = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:RECT_CORNECR_RADIUS]; [stroke stroke]; But for some reason the corner curves look thinker than the sides. If you look at the UIButton's default frame it's very uniform. A is a UIButton, B is a custom button. Any ideas how I can make it more like the UIButton. 回答1: You are stroking the bounds of your button. This will draw your line centred over the edge

BezierPath Rotation in a UIView

試著忘記壹切 提交于 2019-12-03 22:47:42
I am drawing a BezierPath on Touch event. Now I have to rotate that Bezier Path on the same location using Gesture Method. But problem is, after rotation its position become change. Its look like the following image.. How can I fix this? The Upper image is the original image. Share your ideas with me.. Thanks in advance Check this in Apple documentation. applyTransform: Transforms all points in the path using the specified affine transform matrix. - (void)applyTransform:(CGAffineTransform)transform I haven't tried this. But here is how to rotate a NSBezierPath from the link rotating

Reposition/resize UIBezierPath

对着背影说爱祢 提交于 2019-12-03 17:50:42
问题 I have a draggable view that has a mask layer on it. The mask layer has a UIBezierPath on it which makes an area on the view see-through/transparent(the effect that i want). My end goal is to change the position and size of the path(not the mask layer!) by passing a CGRect that is calculated based on the intersection of my view and another rectangle(Basically I want to hide the area that intersects). 1)How I create my mask and path(creates a see-through rectangle on my view): self.maskLayer =

UIBezierPath with color gradient

Deadly 提交于 2019-12-03 17:20:28
问题 I've got an question about UIBezierPath. For example I've got this path: Now I want to have a color gradient from white to red. From left to right. Here is my code: UIBezierPath *bezierPath; bezierPath = [UIBezierPath bezierPathWithArcCenter:_center radius:_radius startAngle:((4 * angle)) endAngle:(((20) * angle)) clockwise:YES]; [bezierPath addLineToPoint:_center]; [bezierPath closePath]; UIColor *color = [UIColor colorWithHue:0/sectors saturation:1. brightness:1. alpha:1]; [color setFill];

How to set Corner Radius to UIBezierPath

吃可爱长大的小学妹 提交于 2019-12-03 16:45:49
I have created following image by UIBezierPath using this code //// Bezier Drawing let bezierPath = UIBezierPath() bezierPath.move(to: CGPoint(x: 360, y: 0)) bezierPath.addCurve(to: CGPoint(x: 360, y: 75), controlPoint1: CGPoint(x: 359.53, y: 30.5), controlPoint2: CGPoint(x: 359.91, y: 55.45)) bezierPath.addCurve(to: CGPoint(x: 360, y: 153.78), controlPoint1: CGPoint(x: 360.35, y: 153.21), controlPoint2: CGPoint(x: 360, y: 153.78)) bezierPath.addCurve(to: CGPoint(x: 180, y: 153.78), controlPoint1: CGPoint(x: 360, y: 153.78), controlPoint2: CGPoint(x: 271.2, y: 212.77)) bezierPath.addCurve(to:

how to draw UIBezierPaths

浪子不回头ぞ 提交于 2019-12-03 16:09:31
Here's what I want to do: I have a UIBezierPath and I want to pass it to some method for it to be drawn. Or simply draw it from the method in which it is created. I'm not sure how to indicate which view it should be drawn in. Do all methods for drawing have to start with - (void)drawRect:(CGRect)rect { ...} ? can I do - (void)drawRect:(CGRect)rect withBezierPath:(UIBezierPath*) bezierPath { ... } ?? How do I call this function, or method, from another method? Deepak Danduprolu drawRect: is something that is invoked automatically when you message setNeedsDisplay or setNeedsDisplayInRect: on a

What is the difference between closing the bezier path using closePath function and closing it manually?

≡放荡痞女 提交于 2019-12-03 13:46:50
I am trying to make a rectangle using UIBezierPath . I adopted two different ways to draw it. Also, I increased the stroke width to 25 px. First method : Using 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]; Output: Second method : Closing the path manually UIBezierPath *bpath = [UIBezierPath bezierPath]; [bpath moveToPoint:CGPointMake(x, y)]; [bpath addLineToPoint:CGPointMake(x + w, y)

How to give cornerRadius for UIBezierPath

我的梦境 提交于 2019-12-03 13:18:04
I created a rectangle using following code and now I need to rounded the corners of this rectangle. but I can't find a property called layer.cornerRadius, can anyone help me ? class OvalLayer: CAShapeLayer { let animationDuration: CFTimeInterval = 0.3 override init() { super.init() fillColor = Colors.green.CGColor path = ovalPathSmall.CGPath } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } var ovalPathStart: UIBezierPath { let path = UIBezierPath(ovalInRect: CGRect(x: 0.0, y: 0.0, width: 100.0, height: 100.0)) return path } } You can use below