• 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
NSAffineTransform on iOS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSAffineTransform on iOS


  • Subject: NSAffineTransform on iOS
  • From: Pascal Harris <email@hidden>
  • Date: Mon, 09 Apr 2012 15:55:45 +0100

I'm trying to write some code for iOS and Wow!  I didn't expect it to be so unfamiliar.  Kind of like walking into a familiar city, like London, and discovering that everyone is speaking Dutch and no one speaks English.  Weird.  I'm slowly getting to grips with the differences and similarities - but I'm a bit perplexed by transforms.  As I say, I'm writing a tile based game and the following code works very nicely in Mac OS X:

	NSGraphicsContext *context = [NSGraphicsContext currentContext];
	[context saveGraphicsState];

	id transform = [NSAffineTransform transform];
	[transform translateXBy:NSMidX(tileFrame) yBy:NSMidY(tileFrame)];
	[transform concat];

	[self drawTile:tileFrame];

	[context restoreGraphicsState];


Unfortunately, my iOS version doesn't work. That isn't to say that it crashes - it just doesn't produce the expected output.

	CGContextRef context = UIGraphicsGetCurrentContext();
	CGContextSaveGState(context);

	CGAffineTransform transform;
	CGAffineTransformTranslate(transform, CGRectGetMidX(tileFrame), CGRectGetMidY(tileFrame));
     	CGContextConcatCTM(context, transform);

	[self drawTile:tileFrame];

	CGContextRestoreGState(context);

I'm sure that my error will be obvious to anyone who isn't a complete newb, but I am - so it isn't obvious to me!

And are there any books that you'd recommend that cover these kind of issues, books to assist a Mac OS X developer write for iOS?
_______________________________________________

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

  • Follow-Ups:
    • Re: NSAffineTransform on iOS
      • From: Dave DeLong <email@hidden>
  • Prev by Date: Re: copy from iCloud to sandbox fails
  • Next by Date: Re: NSAffineTransform on iOS
  • Previous by thread: Re: -[NSURL path] "If the path has a trailing slash it is stripped"
  • Next by thread: Re: NSAffineTransform on iOS
  • Index(es):
    • Date
    • Thread