• 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: draw NSAttributedstring with transparency
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: draw NSAttributedstring with transparency


  • Subject: Re: draw NSAttributedstring with transparency
  • From: Steve Christensen <email@hidden>
  • Date: Fri, 23 Jul 2010 06:50:12 -0700

On Jul 23, 2010, at 3:53 AM, Bernard Knaepen wrote:

> I need to draw an NSAttributedString over an image. The characters of the string might have different sizes, fonts and colors.
>
> I am currently using the drawAtPoint method but I would like to specify a global opacity (transparency) to draw the string. Is there a way to do this or should I scan the whole string and make the changes to each character color individually by using the colorWithAlphaComponent method?

Something like this, perhaps:

NSGraphicsContext* nsContext = [NSGraphicsContext currentContent];
CGContextRef cgContext = (CGContextRef)[nsContext graphicsPort];

[nsContext saveGraphicsState];
[nsContext setCompositingOperation:NSCompositeSourceOver];
CGContextSetAlpha(cgContext, 0.5);

[theString drawAtPoint:thePoint];

[nsContext restoreGraphicsState];

_______________________________________________

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: draw NSAttributedstring with transparency
      • From: Bernard Knaepen <email@hidden>
References: 
 >draw NSAttributedstring with transparency (From: Bernard Knaepen <email@hidden>)

  • Prev by Date: Re: Transparent IKImageBrowserView
  • Next by Date: Re: draw NSAttributedstring with transparency
  • Previous by thread: Re: draw NSAttributedstring with transparency
  • Next by thread: Re: draw NSAttributedstring with transparency
  • Index(es):
    • Date
    • Thread