Re: view content not tracking window size
Re: view content not tracking window size
- Subject: Re: view content not tracking window size
- From: N!K <email@hidden>
- Date: Mon, 29 Sep 2014 21:22:03 -0700
On Sep 27, 2014, at 12:27 AM, Ken Thomases <email@hidden> wrote:
> On Sep 27, 2014, at 2:11 AM, N!K <email@hidden> wrote:
>
>> On Sep 25, 2014, at 10:49 PM, Ken Thomases <email@hidden> wrote:
>>
>>> On Sep 25, 2014, at 9:38 PM, N!K <email@hidden> 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.
There is nothing to rehash; I was unable to use your inputs.
> But don't send the reasons to _me_. Send them to the list and/or the StackOverflow community.
I will immediately comment on your answer in StackOverflow. Interested cocoa dev readers can see it there. I don’t see a need to clutter this forum with the details.
>
>>> 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?
The path did not scale while manually resizing the window.
>
> In any case, you definitely shouldn't set the bounds in -drawRect:. That method is for drawing, not for modifying the view.
Not so. This is where scaling the content works. Please see my response in cocoa-dev today, 9/29/2014 8:35 PM, about success using Graham Cox’s outline.
>
> Regards,
> Ken
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden