Note that there are some explanatory texts on larger screens.

plurals
  1. POAbout cutting of / cropping a uiview
    primarykey
    data
    text
    <p>so i have a uiview that is initialized with a frame that has the height and width that is present for the user, i want the user to be able to draw inside this frame but when the user presses a button, i want the view to cut off that extra wasted space so that the frame is only as big as what the user was drawing. I tried to do something like this </p> <pre><code>CGRect boundbox = CGPathGetBoundingBox([myPath CGPath]); boundbox.origin.x = self.frame.origin.x; boundbox.origin.y = self.frame.origin.y; self.frame = boundbox; </code></pre> <p>However, this does not remove that extra wasted space, it only resizes the view, so that the drawn content looks smaller than previously. What i would like to do instead is to remove that "whitespace", i was thinking if it could be possible to scale up the content of the uiview, but im not sure.</p> <p>To clarify what i mean:</p> <p><img src="https://i.stack.imgur.com/Nv6ZT.png" alt="enter image description here"></p> <p>The red border is the area / frame that the user can draw on, the text in the middle is a drawing, when the user presses a button, i want the frame to only encircle the drawing like in figure 2.</p> <p><img src="https://i.stack.imgur.com/vA8NO.png" alt="enter image description here"></p> <p>Now lets say i have the following scenario, i have drawn a circle on the middle of the screen.</p> <p><img src="https://i.stack.imgur.com/9lNDD.png" alt="enter image description here"></p> <p>When i then press the button, the scale remains the same but the circle is still in the same position but we have now changed the draw area, so the circle / drawing will look like its cut off like in figure 4.</p> <p><img src="https://i.stack.imgur.com/eEDuI.png" alt="enter image description here"></p> <p>What i want to do is to move the drawing / bezier path so that it is positioned in the middle of the frame. So that the red area encircles the blue circle.</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.
    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