uibezierpath

Drawing a grid in UIScrollView's subview allocates huge memory

独自空忆成欢 提交于 2019-11-30 16:39:23
I'm trying to create a UIView in UIScrollView that contains just a simple grid (lines as rows and columns) drown by UIBezierPath or using the CG functions. The problem is, that when I have larger content size of the UIScrollView (as well as the larger subview), during the drawing of the grid huge amount of memory is allocated (50MB or more). UIViewController which includes just UIScrollView over whole scene - adding subview in viewDidLoad: @interface TTTTestViewController() @property (weak, nonatomic) IBOutlet UIScrollView *scrollView; @end @implementation TTTTestViewController -(void

Drawing a grid in UIScrollView's subview allocates huge memory

百般思念 提交于 2019-11-30 16:19:42
问题 I'm trying to create a UIView in UIScrollView that contains just a simple grid (lines as rows and columns) drown by UIBezierPath or using the CG functions. The problem is, that when I have larger content size of the UIScrollView (as well as the larger subview), during the drawing of the grid huge amount of memory is allocated (50MB or more). UIViewController which includes just UIScrollView over whole scene - adding subview in viewDidLoad: @interface TTTTestViewController() @property (weak,

How to generate CGPoint-Array out of UIBezierPath (to touch-slide object along given path) [duplicate]

眉间皱痕 提交于 2019-11-30 15:51:52
问题 This question already has an answer here : Drag UIView around Shape Comprised of CGMutablePaths (1 answer) Closed 3 years ago . I have a UIBezierPath (curved like an '8', with only 4 points in it) and I need to make some kind of CGPoint-Array out of it. Any ideas? thanx! edit: I have my bezier initlialized like that -(void) initBezier { theBezierPath = [UIBezierPath bezierPath]; [theBezierPath moveToPoint:P(211.00, 31.00)]; [theBezierPath addCurveToPoint:P(870.00, 191.00) controlPoint1:P(432

How to generate CGPoint-Array out of UIBezierPath (to touch-slide object along given path) [duplicate]

♀尐吖头ヾ 提交于 2019-11-30 15:24:09
This question already has an answer here: Drag UIView around Shape Comprised of CGMutablePaths 1 answer I have a UIBezierPath (curved like an '8', with only 4 points in it) and I need to make some kind of CGPoint-Array out of it. Any ideas? thanx! edit: I have my bezier initlialized like that -(void) initBezier { theBezierPath = [UIBezierPath bezierPath]; [theBezierPath moveToPoint:P(211.00, 31.00)]; [theBezierPath addCurveToPoint:P(870.00, 191.00) controlPoint1:P(432.00, -11.00) controlPoint2:P(593.00, 209.00)]; [theBezierPath addCurveToPoint:P(731.00, 28.00) controlPoint1:P(1061.95, 178.53)

Get points from a UIBezierPath

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 09:31:01
I drew the above BezierPath by doing: // location is where the user touches screen. // location will be the maximum of the graph CGPoint origin = CGPointMake(xStart, 620.0); CGPoint endpt = CGPointMake(xEnd, 620.0); CGPoint midpt1 = midPointForPoints(origin, location); CGPoint midpt2 = midPointForPoints(location, endpt); UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:origin]; [path addQuadCurveToPoint:location controlPoint:CGPointMake(midpt1.x, midpt1.y+50)]; [path addQuadCurveToPoint:endpt controlPoint:CGPointMake(midpt2.x, midpt2.y+50)]; [shapeLayer setPath:path.CGPath];

Drag ball over circle path in Swift

泄露秘密 提交于 2019-11-30 09:19:16
I made a circle Path, the center of the circle path is in the middle of the view. Then, I made a ball that can move only on the circle path (at least this is what I want it to be): I made a function that move the ball wherever I drag him (on the circle path only), but for some reason whenever I drag it, it gets crazy and doesn't move as I want it to move. This is my code so far: class ViewController: UIViewController { var midViewX = CGFloat() var midViewY = CGFloat() var circlePath2 = UIBezierPath() var shapeLayer2 = CAShapeLayer() override func viewDidLoad() { super.viewDidLoad() midViewX =

How to draw Bezier curves with native Javascript code without ctx.bezierCurveTo?

一曲冷凌霜 提交于 2019-11-30 08:41:35
I need to draw and get coordinates of bezier curves of each steps with native Javascript without ctx.bezierCurveTo method. I found several resources, but I confused. Esspecially this looks pretty close, but I couldnt implemented clearly. How can I accomplish this? hobberwickey You can plot out the Bezier: bezier = function(t, p0, p1, p2, p3){ var cX = 3 * (p1.x - p0.x), bX = 3 * (p2.x - p1.x) - cX, aX = p3.x - p0.x - cX - bX; var cY = 3 * (p1.y - p0.y), bY = 3 * (p2.y - p1.y) - cY, aY = p3.y - p0.y - cY - bY; var x = (aX * Math.pow(t, 3)) + (bX * Math.pow(t, 2)) + (cX * t) + p0.x; var y = (aY

CABasicAnimation with CALayer path doesn't animate

笑着哭i 提交于 2019-11-30 07:52:50
问题 I'm trying to animation the transition of a CALayer from normal corners to rounded corners. I only want to round the top corners, so I am using a UIBezierPath. Here's the code: UIRectCorner corners = UIRectCornerTopLeft | UIRectCornerTopRight; UIBezierPath* newPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(8.0f, 8.0f)]; UIBezierPath* oldPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii

How to bring UIBezierPath to the back of a MKAnnotation object?

你说的曾经没有我的故事 提交于 2019-11-30 07:34:40
In my app, user draws a shape on map and using UIBeizerPath i am drawing that path. Then based on the coordinates of the path i am displaying the results which are only in that area. Everything works great except that now when Annotations drops on the Map view the pins looks like they are behind the path which means path looks in the front. I am using this code to display the Annotation and path : -(void)clearAnnotationAndPath:(id)sender { [_mapView removeAnnotations:_mapView.annotations]; path = [UIBezierPath bezierPath]; [shapeLayer removeFromSuperlayer]; } - (void)handleGesture:

UIBezierPath: How to add a border around a view with rounded corners?

无人久伴 提交于 2019-11-30 07:06:42
问题 I am using UIBezierPath to have my imageview have round corners but I also want to add a border to the imageview. Keep in mind the top is a uiimage and the bottom is a label. Currently using this code produces: let rectShape = CAShapeLayer() rectShape.bounds = myCell2.NewFeedImageView.frame rectShape.position = myCell2.NewFeedImageView.center rectShape.path = UIBezierPath(roundedRect: myCell2.NewFeedImageView.bounds, byRoundingCorners: .TopRight | .TopLeft, cornerRadii: CGSize(width: 25,