On Sep 27, 2014, at 2:11 AM, N!K <[email protected]> wrote:
> On Sep 25, 2014, at 10:49 PM, Ken Thomases <[email protected]> wrote: > >> On Sep 25, 2014, at 9:38 PM, N!K <[email protected]> wrote: >> >>> In Xcode 5 OSX, not ios, I have created a custom view and set auto layout >>> constraints so that the custom view's sides stay a fixed distance from the >>> content view's frame. The custom view resizes correctly while dragging the >>> window's corner while running, but the content of the custom view remains >>> fixed in size. Shrinking the window can crop the content, and expanding it >>> provides lots of open space next to the unchanging content. >>> >>> The content consists of a Bezier path, which is created in initwithframe >>> and executed in drawrect with [path stroke]. NSLog shows that bounds is >>> changing while resizing. >>> >>> How can I make the content resize along with the view and window? The >>> window, view, and drawing documents explain how to set up a view, but I >>> haven't found any discussion of content tracking the window size. >> >> You asked this at >> <http://stackoverflow.com/questions/26006747/xcode-5-auto-layout-view-stretches-but-not-the-views-contents/26007383#26007383> >> and I answered you there. > > Thank you for your response there, but I was not able to use it. If you > like, I can send you the reasons in detail. Well, if you don't explain then people are just going to keep rehashing the obvious approaches. But don't send the reasons to _me_. Send them to the list and/or the StackOverflow community. >> In summary, the easiest thing to do is set the bounds once. If you ever set >> the bounds of a view, then they stop automatically tracking the frame. >> Therefore, the coordinate space ends up scaling. Since the bounds are no >> longer always equal to the frame, Cocoa effectively has to transform the >> coordinate space inside the view to the coordinate space of the containing >> view(s) and, ultimately, the window. That transform is exactly the sort of >> stretching you seem to be expecting. >> >> What you set the bounds to is up to you. You could set the bounds to the >> unit square and then do all of your calculations based on the fraction of >> the view that you want to measure. So, x = 0 would be the left edge and x = >> 1 would be the right edge. x = 0.5 would be the center. x = 1/3.0 would be >> one third of the way across. Etc. > > Simply setting the bounds is very attractive. Unfortunately, setting the > bounds did not work, in initWithFrame or drawRect. What does "did not work" mean? What were the results? In any case, you definitely shouldn't set the bounds in -drawRect:. That method is for drawing, not for modifying the view. Regards, Ken _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
