uibezierpath

Restricting pan gesture to move to 90 degree

爱⌒轻易说出口 提交于 2019-12-13 09:24:07
问题 If I have created a line for ex. shown in the figure as connecting A and B through CAShapeLayer and in that line's centre I have a UIView which has pan gesture integrated in it. How to make that UIView to move to a certain direction that creates 90 degrees to that line as shown in the figure the red line indicated the direction that the UIView can be moved? The mid-point should start moving from the centre of the line, in the direction that shown in the figure that I have updated. 回答1: I

Round out the top right and left corners of a view?

拈花ヽ惹草 提交于 2019-12-13 08:31:38
问题 I'm trying to figure out how to mask a UIView to display a shape that represents a Square with half of a circle sitting ontop of it. Basically, it would be like applying a border radius to only the top two corners to round them out and create an arc. I'm using swift, and this is driving me crazy. EDIT: CornerRadius does not do what I want. I feel like I'll have to use a CGShapeLayer but I'm not sure how to create the arc. EDIT2: EDIT3: Considering explaining what I want, providing pictures,

Is UIBezierPath the best way to make a movable rounded rectangle?

爱⌒轻易说出口 提交于 2019-12-13 07:01:30
问题 I'm making a UISlider from scratch. I started by making a rounded rectangle, which I did using the code below: CGRect frame = CGRectMake(10, 10, self.frame.size.width, 10); UIBezierPath* path = [UIBezierPath bezierPathWithRoundedRect:frame cornerRadius:10.0]; [[UIColor blueColor] setFill]; [path fill]; I saw some other options to make a rounded rectangle but thought this was the quickest way. Are there any limitations with making one using UIBezierPath? Namely, the slider needs to be able to

Draw and Erase on ImageView using UIBezierPath

烂漫一生 提交于 2019-12-13 04:46:30
问题 I write this link's answer code to create ImageViewLayer and Imageview. StackOverflow Link This link gives me the below result. It's work fine .But I want ,when user press the original button... and then touches with finger it remove the clear area ang fill with the previous one. And how to create Undo Functionality for this..If any question regarding this please add your comment..Please help me... 回答1: how to draw CALayer with line path like simulate eraser effect? this is the post i get the

Understand moveToPoint and addLineToPoint methods of UIBezierPath?

耗尽温柔 提交于 2019-12-13 02:15:02
问题 My main purpose is of creating a line which has origin point at center of other UIBezierPath which is ROUND in look. let startAngle = CGFloat(-M_PI_2) let endAngle = CGFloat(M_PI + M_PI_2) println("Start Angle \(startAngle) , End Angle \(endAngle)") let centerPoint = CGPointMake(CGRectGetWidth(frame)/2 , CGRectGetHeight(frame)/2) self.staticLayer.path = UIBezierPath(arcCenter:centerPoint, radius: CGRectGetWidth(frame)/2 - 30.0, startAngle:startAngle, endAngle:endAngle, clockwise: true).CGPath

UIBezierPath in Swift: Path gets closed very weirdly

若如初见. 提交于 2019-12-13 01:52:19
问题 I am using the extension from Drawing class drawing straight lines instead of curved lines to interpolate a u-shape drawing. Unfortunately the path gets closed in a weird way: What it should look like: What it actually looks like: My code: override func drawRect(rect: CGRect) { let points: [CGPoint] = [CGPoint(x: 78, y: 99), CGPoint(x: 78, y: 128), CGPoint(x: 78, y: 173), CGPoint(x: 84, y: 199), CGPoint(x: 95, y: 223), CGPoint(x: 112, y: 240), CGPoint(x: 136, y: 243), CGPoint(x: 170, y: 236),

Connecting UIButtons by drawing a line

限于喜欢 提交于 2019-12-13 01:25:01
问题 I need to connect those buttons with a line but have issues as you can see on the screenshot. I need the last line to go vertical (green circles). Any suggestions? here is the code: @IBAction func drawButtons (sender: AnyObject) { buttonContainerView.removeFromSuperview() // Clear containerView buttonContainerView = UIView() // Create a new instance let buttonCount = array.count let n = Int(self.view.frame.size.width) / 90 //check how many buttons can fit in the screen let buttonsPerRow = n

Artefact drawing in Swift

为君一笑 提交于 2019-12-12 13:29:44
问题 The code below draws lines by overriding touches, however there is an artefact that persists when drawing, seen in the images below. When changing direction while zig zagging drawing across the screen, sometimes the line turns into a flat straight corner instead of remaining circular. The artefact is also experienced when drawing on the spot in small circles, the drawing point flashes half circles sometimes leaving half circles and partial circle residue when the finger leave the screen. The

append arrowhead to UIBezierPath

帅比萌擦擦* 提交于 2019-12-12 13:28:09
问题 I need your help: I am trying to create a graph using UIBezierPaths with variable widths and consisting of a bezier curve with two control points. Now I'd like to add arrow heads to the end (right hand side) of these paths. Is there a way to do this i.e. by appending a subpath with a smaller lineWidth which contains a triangle? here is a sample picture of some paths to which I'd like to add arrowheads: Thanks for your help! 回答1: Let's assume you drew one of arcs like so: UIBezierPath *path =

UIBezierPath manipulation on iOS

心已入冬 提交于 2019-12-12 11:36:55
问题 I'm starting out with a straight line and I would like the user to be able to touch and drag the line so that it curves. Effectively, they would have the ability to manipulate the line into a wave shape. I'm not sure of the easiest way of achieving this technically. I had started by creating an array of UIBezierPaths of cubic curves with the intention of manipulating the control points - but it appears that it is not possible to alter the control points of UIBezierPaths once they have been