• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSView and Changing View Bounds...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSView and Changing View Bounds...


  • Subject: NSView and Changing View Bounds...
  • From: "Peters, Brandon" <email@hidden>
  • Date: Sun, 12 Oct 2014 14:20:45 +0000
  • Thread-topic: NSView and Changing View Bounds...

I have a custom NSView in which the bounds are changed to shrink or enlarge an image whenever a magnification event is taking place. Printing out to the console shows the bounds origin is changing, but I am not seeing this effect in the application’s window. I override -(void)magnifyWithEvent to make this happen:

-(void)magnifyWithEvent:(NSEvent *)event {

    CGFloat zoomFactor = [event magnification] + 1.0;

    CGSize newSize = [self bounds].size;

    newSize.width = newSize.width * zoomFactor;
    newSize.height = newSize.height * zoomFactor;

    [self setBoundsSize:newSize];

    CGSize viewFrameSize = [self frame].size;
    CGPoint newOrigin;
    newOrigin.x = (viewFrameSize.width - newSize.width) / 2.0;
    newOrigin.y = (viewFrameSize.height - newSize.height) / 2.0;

    [self setBoundsOrigin:newOrigin];

    [self setNeedsDisplay:YES];

}

Effectively, this should center the bounds in the view’s frame and the image should appear centered, but instead I see the image being anchored to the lower left corner of the view’s frame. Am I misunderstand how this should work? Do I need to investigate a different solution?
_______________________________________________

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


  • Prev by Date: Re: Kerning Pairs
  • Next by Date: Re: Kerning Pairs
  • Previous by thread: Is this a good implementation of optimized-zoom?
  • Next by thread: Code signing problem using shared framework in Yosemite
  • Index(es):
    • Date
    • Thread