• 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
Re: Affine transform not being applied to subviews
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Affine transform not being applied to subviews


  • Subject: Re: Affine transform not being applied to subviews
  • From: Ken Tozier <email@hidden>
  • Date: Fri, 22 May 2009 00:26:11 -0400

Thanks Graham

It took a bit of trial and error, but scaleUnitSquareToSize seems to do what I want. I ripped out all the transform code and just wrote a simple override to setFrame for the page view

- (void) setFrame:(NSRect) inFrame
{
	NSSize		currentSize		= [self frame].size;

	float		scale			= inFrame.size.height / currentSize.height;

	[self scaleUnitSquareToSize: NSMakeSize(scale, scale)];
	[super setFrame: inFrame];
}


Much easier

- Ken

On May 21, 2009, at 10:59 PM, Graham Cox wrote:


On 22/05/2009, at 12:52 PM, Ken Tozier wrote:

- (void) drawRect:(NSRect) inRect
{
NSAffineTransform *transform = [self transform];

[transform concat];

[[NSColor whiteColor] set];
NSRectFillUsingOperation([self frame], NSCompositeSourceOver);

[[NSColor blackColor] set];
NSFrameRectWithWidthUsingOperation([self frame], 1, NSCompositeSourceOver);
}


Setting a transform in -drawRect: will only apply it to whatever is drawn within that method. That doesn't include the subviews.

What are you trying to do? If you need to scale the page view then use -scaleUnitSquareToSize: and adjust the frame. To translate use a scrollview. To rotate, use -rotateToAngle:

--Graham



_______________________________________________

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


References: 
 >Affine transform not being applied to subviews (From: Ken Tozier <email@hidden>)
 >Re: Affine transform not being applied to subviews (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Ask for NSTextField
  • Next by Date: Re: How to set dpi of an image
  • Previous by thread: Re: Affine transform not being applied to subviews
  • Next by thread: Re: Affine transform not being applied to subviews
  • Index(es):
    • Date
    • Thread