• 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: iPhone: subclassing UIView for blendmode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iPhone: subclassing UIView for blendmode


  • Subject: Re: iPhone: subclassing UIView for blendmode
  • From: David Duncan <email@hidden>
  • Date: Fri, 22 Jan 2010 09:32:35 -0800

On Jan 22, 2010, at 6:49 AM, Eric E. Dolecki wrote:

> Sorry this is a noob question, but I am try to get blendmode to work for
> images. What I have done so far that seems to do nothing:
>
> I create a new class called ImageView which subclasses UIView. I have done
> nothing in the initWithFrame, only in drawRect:
>
> - (void)drawRect:(CGRect)rect {
>
> CGContextRef context = UIGraphicsGetCurrentContext();
>
> CGContextSetBlendMode(context, kCGBlendModeMultiply);
>
> }

<snip>

> I am not seeing the blend mode applied - it seems nothing is happening. Do I
> need to call a method of my own after I add the subView to the subclassed
> UIView in order for it to take? I think I am missing something very basic
> here.


Your getting exactly what you asked for. The blend mode applies to content drawn into that context, but you aren't drawing anything into the context. Since every invocation of -drawRect: draws to a different context, you get absolutely nothing from doing this.

And since you seem to want to blend between views, I'll just go ahead and say there is no way to change the blend mode used for blending views together. If you want to apply blend modes, you will have to do the rendering yourself with that limitation in mind.
--
David Duncan
Apple DTS Animation and Printing

_______________________________________________

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: 
 >iPhone: subclassing UIView for blendmode (From: "Eric E. Dolecki" <email@hidden>)

  • Prev by Date: Re: CALayer resizing puzzle
  • Next by Date: Re: UIImageView display as "multiply"?
  • Previous by thread: iPhone: subclassing UIView for blendmode
  • Next by thread: KVO and object release timing (for a NSCollectionView)
  • Index(es):
    • Date
    • Thread