Note that there are some explanatory texts on larger screens.

plurals
  1. POCALayer performance problem: animating a line anchored between two UIViews
    primarykey
    data
    text
    <p>I have an iPad app that has draggable UIViews contained in a larger parent UIView (which i'll call the main view). One of the features of the app is the ability to drag between two views to connect them. When dragging i render a line in a CALayer that is rooted on the view that you started dragging on and ends on the user's finger. If the user ends the drag on top of another view they become attached. </p> <p>When views are attached there is a line permanently drawn between them.</p> <p>So in the current implementation there are two CALayers which are sublayers of the main view. One is the linkLayer, which renders the existing links between views. the other is the linkLineLayer which renders the line the user is currently drawing w/ a drag action.</p> <p>When dragging occurs and an new drag event comes in, i call [linkLineLayer setNeedsDisplay]. similarly, when a user is dragging a view around i call [linkLayer setNeedsDisplay].</p> <p>the performance is terrible on the actual device, so im guessing that this isn't the way to go. What alternatives are there to draw lines between views (or points in a view) such that i can update them frequently when dragging a view or dragging a line between views without wrecking the framerate and hammering the device cpu?</p> <p><strong>Update</strong> So last night i went in and made two fixes that made a huge difference: 1.) all link lines are their own layer. as a view is being dragged around i refresh only the link lines associated w/ that specific view.<br> 2.) updated the "dragging line" to be a layer that whose size is limited to the size of the line being rendered. i adjust the layer bounds as the user's finger is moving. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload