• 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: CALayers - printing and flippedness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CALayers - printing and flippedness


  • Subject: Re: CALayers - printing and flippedness
  • From: Gideon King <email@hidden>
  • Date: Tue, 14 Sep 2010 18:05:31 +1000

Thanks Scott, but I also tried with the layer being owned by the view, and nothing printed when I tried to print the view. I took it right back to a simple form where it just creates the layer and paints it red - works on screen but still doesn't print.

- (void)awakeFromNib {
	CALayer *myLayer = [CALayer layer];
	[self setLayer:myLayer];
	[self setWantsLayer:YES];
	myLayer.delegate = self;
	[myLayer setNeedsDisplay];
}

- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx {
	CGContextRef gcontext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
	CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
	CGFloat opaqueRed[4] = { 1, 0, 0, 1 };
	CGColorRef color = CGColorCreate(colorSpace, opaqueRed);
	CGContextSetFillColorWithColor(gcontext, color);
	CGContextFillRect(gcontext, layer.bounds);
	CFRelease(color);
	CFRelease(colorSpace);
}

On 14/09/2010, at 4:33 PM, Scott Anguish wrote:

>
> Yeah, this is a confusing issue.
>
> UIView’s have a coordinate origin at the top, NSView’s at the bottom. Any default layer you make on iOS will have the the same origin, and same on OS X.
>
> It’s hard to tell why you’re using layer’s in this case rather than strictly the views though.
>
>

I'm just experimenting with the different options at the moment, and when I couldn't get what I saw on the screen to print, I tried with the sublayer.

So I presume that if I have a layer backed view and I want to add a bunch of sub-layers, I would have to create a layer owning view, and add those as sublayers of its layer, and if I then wanted another layer backed view, I would add that as a subview of the layer owning view? I guess there are two things that lead me to ask this question: I want to be able to make use of the efficiency and lightweight nature of the layers and some of the specialist ones like being able to display videos, but at the same time, I will need to add at least a text view (and possibly other views) on top for user input.

Regards

Gideon
_______________________________________________

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: 
 >CALayers - printing and flippedness (From: Gideon King <email@hidden>)
 >Re: CALayers - printing and flippedness (From: Scott Anguish <email@hidden>)
 >Re: CALayers - printing and flippedness (From: Gideon King <email@hidden>)

  • Prev by Date: Layer-backed view artifact
  • Next by Date: Re: CALayers - printing and flippedness
  • Previous by thread: Re: CALayers - printing and flippedness
  • Next by thread: Re: CALayers - printing and flippedness
  • Index(es):
    • Date
    • Thread