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 20:29:25 -0700
Thank you for the reference. I have not had to deal with images (except in Hillegas’ book example), so I have not read about Quartz. It sounds like it has other uses, like line drawings.
I’ll follow up with this soon, and yes, some examples will be a big help. I often find that things like Apple’s documentation clearly and exactly defines functions, but then I have no idea how to use them. If I can find examples of code, the Aha! light goes on.
On Sep 27, 2014, at 5:41 AM, email@hidden wrote:
> It's the same bezier drawing. Just an API to draw into a context with a little built in convenience methods.
>
> You should really read more about Quartz to understand how this is really not different. Just convenient resizing.
>
> I can share some example code if it helps.
>
> Sent from my iPhone
>
> On 2014/09/27, at 16:14, N!K <email@hidden> wrote:
>
>> Thanks, but I want to stay with a line drawing, Bezier path, not images.
>> Also, I don’t know how to do anything with images.
>>
>> Nick
>>
>>
>> On Sep 25, 2014, at 10:42 PM, email@hidden wrote:
>>
>>>
>>>
>>> On 2014/09/26, at 11:38, 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.
>>>>
>>>> Thanks,
>>>>
>>>>
>>>>
>>>> Nick
>>>
>>> One approach is to use an NSImage inside an NSImageView.
>>>
>>> NSImage has an awesome class method that takes a block argument for drawing.
>>>
>>> + (id)imageWithSize:(NSSize)size flipped:(BOOL)drawingHandlerShouldBeCalledWithFlippedContext drawingHandler:(BOOL (^)(NSRect dstRect))drawingHandler
>>>
>>> The image view helps for maintaining the aspect and scaling desired.
>>>
>>> With this combo you can then simply use auto layout constraints to keep it a minimum size or what have you.
>>
_______________________________________________
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