CALayer BlendMode - iphone

I am creating a simple iOS application in which I have two CALayers, I want to add the blend effect on the upper CALayer to display the content on the second layer. I dont want to do it alpha. Is there any way to do this without changing the alpha?

iOS (as of 5.1) does not currently support any blend effects on CALayer. In my testing, the compositingFilter property is ignored.

There's a tricky way to achieve this.
compositingFilter works but filter names should be like subtractBlendMode (lower camel case), not CISubtractBlendMode.
Here is a demo:
https://github.com/arthurschiller/CompositingFilters

Use property
opacity
of CALayer as there is nothing such as alpha. Its opacity instead of alpha
so try setting opacity of the layers.

Related

Can you set different CALayer border width on different side?

I am trying to create a pseudo-3D square (like a scrabble tile) and I was thinking of faking it with borders. But then I couldn't find a way to set different width for different side.
Is this possible at all? If not, does anyone have any recommendation on how to do this in CALayer?
Oh, one caveat, I am already using shadow, so can't use that to fake the bevel.
Not possible with ordinary CALayer properties. You'd have to inset your layer and draw the different borders in the drawing method, or add a second larger layer to take care of that inside its drawing.
You could possibly do it with the layer's shadow properties, using -shadowOffset to only render it on two sides. However, to make it really nice you probably have to draw it yourself.

How can I fade a View with a CAEAGLLayer

I'm currently looking for a way to change the alpha value of a view with a CAEAGLLayer. Setting self.alpha doesn't work, so I think there must be some concept here I don't understand. The app I'm building has an opengl layer over live footage from the iPhone/iPod camera, and I'd like to fade this in and out. I've also tried setting the CAEAGLLayer's opaque and opacity value, which also won't work. Thanks for any thoughts you may have.
I am trying to do something similar, i.e. have just the background of the CAEAGLLayer be transparent, so I can draw over a photo. I have managed to fade the whole thing in and out setting the Alpha value on the layer itself in the layout editor of the Nib, which might work for you, but is not quite the effect I want. What I really want is just a transparent background and there is discussion of how to achieve that here:
http://www.iphonedevsdk.com/forum/iphone-sdk-development/20081-merging-content-uiimageview-eaglview.html
Although I haven't managed to get what they describe working yet ... :-(

Easy way to blur label

Need to create blurred shadow under UILabel. Same text but with blur and offset. Since NSShadow not supported in the iPhone SDK only way I see is Quartz render. Is there simpliest solution ?
Thanks
I provide code to draw a shadow around a UILabel in my answer to this question. For an example of this in action, see the sample project I've created. A shadow of the same color as the text provides a nice blurring effect to the text in a label.
For 3.1 and below, no. You must use CoreGraphics.
For 3.2 and above, you can get the layer, and set the shadowRadius property.

Animate a GIF using Core Animation layers?

I'm trying to animate a GIF and I hit a roadblock. I have an example of what I'm trying to do that uses the individual frames of the GIF and setting the animationImages property of a UIView. However in my project, the thing I want to animate is drawn using Layers. I'm looking for a quick and easy way to animate the frames without introducing too much complexity. Is there any animationImages equivalent with Layers? Does anybody have any ideas?
Another solution:
The contents property of a CALayer is animatable. Meaning you can create a CAKeyFrameAnimation and supply it with an array of images for each frame. You can also set the timing of it.
Note, will likely work better with PNGs
Maybe that helps instead.
Here you go, enjoy:
http://github.com/jamesu/glgif

Can you animate gradients using Quartz in an iPhone?

I am new to iPhone development and am currently toying with recreating a charting tool I developed for Silverlight.
Currently I'm using a gradient to 'fill' a rectangle representing a bar within a chart. Is it possible to animate this gradient so it changes colour when a user touches the bar within the chart.
I have looked through the Core Animation guides provided by Apple but cannot see a property which targets gradients. I suppose I could use a transition to fade between two rects, one of which has my starting gradient and the second with the 'touched' version but this would mean obviously drawing multiple rect objects for each bar with I assume extra performace overheads.
Any ideas?
Yes, indeed you can animated gradients with Core Animation.
The CAGradientLayer class that came out in 3.0 has a nice API for rendering gradients into a layer and animating color and color-stop changes as well.
I did a post on this class a little while back, along with some sample code that's linked at the bottom.
In the sample I animate the gradient by building a CABasicAnimation, but you can implicitly animate the change as well, by just passing a new array of colors to the gradient layer's colors property. Use implicit animations unless you have a reason not to.
Check that out and let me know if you have any questions specific to the UI you're trying to animate.