> On 2014/09/26, at 11:38, N!K <pu56ucl...@alumni.purdue.edu> 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 (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to