cashapelayer

How to make my UIBezierPath animated with CAShapeLayer?

一个人想着一个人 提交于 2019-12-17 10:46:41
问题 I'm trying to animate a UIBezierPath and I've installed a CAShapeLayer to try to do it. Unfortunately the animation isn't working and I'm not sure any of the layers are having any affect (as the code is doing the same thing it was doing before I had the layers). Here is the actual code - would love any help. Draw2D is an implementation of UIView that is embedded in a UIViewController. All the drawing is happening inside the Draw2D class. The call to [_helper createDrawing... ] simply

Programmatically created UIView's frame is 0

感情迁移 提交于 2019-12-13 18:19:02
问题 Cannot access uiview's frame after setting it's layout. Frame, and center is given as 0,0 points. I should also mention that there are no storyboard's in this project. All views and everything are created programmatically. I have created a UIView resultView programmatically and added it as a subview in scrollView , which is also added as a subview of view , then set it's constraints, anchors in a method called setupLayout() I call setupLayout() in viewDidLoad() and after that method, I call

Getting issue in CGPath Scale

血红的双手。 提交于 2019-12-13 14:35:09
问题 I am drawing polygon using CGPath and adding to CAShapeLayer .I want to scale my CGPath when user click on it. I know how to scale CGPath . But when i click my CGPath , my CGPath drawing far from centre while i am drawing polygon in centre. CGAffineTransform scaleTransform = CGAffineTransformMakeScale(scaleFactor, scaleFactor); CGPathRef oldPath = polygonLayer.path; CGPathRef scaledPath = CGPathCreateCopyByTransformingPath(oldPath, &scaleTransform); polygonLayer.path = scaledPath; 回答1: The

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,

How to remove CAShapeLayer along user drag?

自古美人都是妖i 提交于 2019-12-12 05:44:52
问题 I am new to painting app ,so please suggest me is there any way to remove. i was googled i am only getting CGContextSetBlendMode(_context, kCGBlendModeClear); but not for CAShape layer UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:CGPointMake(touchPoint.x,touchPoint.y)]; [path addLineToPoint:CGPointMake(startingPoint.x,startingPoint.y)]; CAShapeLayer *shapeLayer = [CAShapeLayer layer]; shapeLayer.path = [path CGPath]; // shapeLayer.strokeColor =kCGBlendModeClear; if(

Laggy UITableView scrolling because of CAShapeLayer (Swift 3)

て烟熏妆下的殇ゞ 提交于 2019-12-12 04:33:13
问题 I have a UITableView within a UIView, and it is made up of custom cells defined by the following class: class CustomAddFriendTableViewCell: UITableViewCell { @IBOutlet weak var UsernameLbl: UILabel! @IBOutlet weak var ProfileImg: UIImageView! @IBOutlet weak var AddFriendBtn: UIButton! } Within the ViewController's tableview(_:cellForRowAt:) method I call the following function to layout the cell's ProfileImg: private func layoutProfilePics(with cell:CustomAddFriendTableViewCell) { //create

Unable to remove CAShapeLayer

Deadly 提交于 2019-12-12 03:58:29
问题 I have a total of 21 lines drawn across the screen for a measurement tool. The lines are drawn as a layer on UIViewController.view. I am attempting to remove the lines as follows. The NSLog statement confirms that I am getting all 21 CAShapeLayers that I am looking for. CAShapeLayer* layer = [[CAShapeLayer alloc]init]; for (UIView *subview in viewsToRemove){ if([subview isKindOfClass:[CAShapeLayer class]]){ count++; NSLog(@"%d: %@", count, subview); [layerArray addObject:layer]; } } for

How to convert CAShapeLayer coordinates to CIRectangleFeature for manual crop

*爱你&永不变心* 提交于 2019-12-12 03:43:57
问题 I am dealing with manual image crop functionality. For this am drawing CAShapeLayer with four coordinates called topLeft, topRight, bottomRight and bottomLeft. User can pan the points and select the crop area. I am stuck at converting these points to Core image coordinates and further cropping with CIPerspectiveTransform. 回答1: Set image to imageView And masking imageView with shape layer. self.imageView = img imageView.layer.mask = shapeLayer // set here your shape layer Now your imageView

How to mark points on a path drawn using CAShapeLayer - Swift?

一曲冷凌霜 提交于 2019-12-12 03:31:48
问题 I have a custom path drawn using CAShapeLayer in a UIView . Its a semicircle, upper half, drawn from left to right. Following is the code used, writted in a UIView subclass: func drawSemicircle() { // drawing an upper half of a circle -> 180 degree to 0 degree, clockwise let startAngle = CGFloat(M_PI) let endAngle = CGFloat(0.0) let centerPoint = CGPointMake(CGRectGetWidth(frame)/2 , CGRectGetHeight(frame)) // path set here let semirCircleLayer = CAShapeLayer() let semirCirclePath =