Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8027869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:56:46+00:00 2026-06-04T23:56:46+00:00

so i have a uiview that is initialized with a frame that has the

  • 0

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

CGRect boundbox = CGPathGetBoundingBox([myPath CGPath]);
boundbox.origin.x = self.frame.origin.x;
boundbox.origin.y = self.frame.origin.y;
self.frame = boundbox;

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.

To clarify what i mean:

enter image description here

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.

enter image description here

Now lets say i have the following scenario, i have drawn a circle on the middle of the screen.

enter image description here

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.

enter image description here

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:56:48+00:00Added an answer on June 4, 2026 at 11:56 pm

    [EDIT]
    Given your drawings. A UIView will not re-position items in it when you change it’s frame property (or it’s CGRect). In this case you will need to track the items drawn YOURSELF, and then when the button is pressed perform the object translations yourself.

    What that means is you will have to find the object that is left most, the object that is topmost, then move all objects left by that amount, and up by that amount so that all objects are (as a grouping) top-left aligned within the view’s frame. After this you will need to self recognize which object is the right most touching and which object is the bottom most touching.

    NOW, since you have already moved the items left-top, the right most point will define your frame width, and the bottom most point will define your frame height.

    IF YOU SO DESIRE, you should be able to zoom in using the properties below after you have done this.

    [First Answer]
    If I understand your question correctly, you may want to still perform your box frame manipulation, but if you wish to scale you may want to look into the

    contentScaleFactor or
    contentStretch
    

    properties.

    contentScaleFactor should scale both dimensions based upon a singular floating point value (i.e. xWidth * scaleFactor, yHeight * scale factor).

    contentStretch is a CGRect which means that it should scale each dimension (axis) separately.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a UIView that contains a UIScrollView and I want to be able
I have a UIView container that has two UIImageView s inside it, one partially
I want to have a UIView subclass that has a border image, but I
I have a UIView that I want to load when the user clicks a
I have a UIView that allows the user to draw a line (myLine) on
I have a UIView that has several UIImageViews as subviews. Each of these subviews
I have a UIView that is pushing a UITableViewController that is contained inside of
I need to create a class that will present a UIVIew and has a
I have a UIView that has 3 sub-views: a header, a center panel, and
I have a UIView that has an image and some buttons as its subviews.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.