Re: iPhone: subclassing UIView for blendmode
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