Re: view content not tracking window size
Re: view content not tracking window size
- Subject: Re: view content not tracking window size
- From: email@hidden
- Date: Fri, 26 Sep 2014 14:42:37 +0900
> 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