iOS - UIScrollVIew with layers - objective-c

Does someone have an example of using a UIScrollView that contains a layer that is playing a CAKeyFrameAnimation or some thing close?
I have the animation playing in there but it doesn't seem to recognize the pinch zoom, I followed a guide for UIImages but the zoom function is specifying a UIView to zoom in on and I would like to zoom in on the layer.
Thanks in advance.

Here is another guide I found with UIImages... Easy enough to figure out from there I think.
http://www.austinbull.com/tutorials/tutorial3.zip

Related

Touching transparent part of Sprite

I am using SpriteBuilder with Cocos2d v3.4
I need to detect touch on sprite ignoring touch in transparent place of CCSprite's bounding box.
I found few solutions (Physics Body, CGPath), but actually detecting transparent pixel seems the best solution.
I tried to use THIS but it is very old solution and not working anymore.
Could someone help me how to achieve this?
Try to create 2 CGRect on the sprite and detect touch only on these rects

Implementing image gestures: UIImageView mode conflicts with pinch gesture

Pan works fine for me, but pinch with recognizer code like this does not:
- (void)pinchDetected:(UIPinchGestureRecognizer *)pinchRecognizer
{
CGFloat scale = pinchRecognizer.scale;
self.imageView.transform = CGAffineTransformScale(self.imageView.transform, scale, scale);
pinchRecognizer.scale = 1.0;
}
What happens is that the image view is continuously resetting the image according to its "mode", whether it's center, aspect fit, etc.
I solved my problem: I'm making my first image viewer, and to learn how to pinch and zoom, I naively googled for how to support gestures, which are not enabled by simply adding an image view to a view controller.
Unfortunately, there are many "tutorials" on this, showing how to program with the gesture recognizers, etc. And I spent a few hours going down this route unnecessarily. I kept going because I felt tantalizingly close to getting things working: The pan gesture was flawless and was "just" zoom that was broken.
(Side question: is there some awesome source for current, iOS 6 "best practices"?)
It turns out, this is the wrong path and needlessly complex for basic gesture recognition. All that's needed is to place the image view in a scroll view. 99% of the programming is taken care of. (I was convinced this had to be the case — I couldn't believe that such core functionality wouldn't be provided by cocoa touch.)

UISlider or UISwitch with a stationary mask?

I've found a gorgeous switch that I'd like to implement in iOS. The artist (#jasonlong) has kindly shared his PSD of the components at 365psd.com, along with a crafty little javascript as a demo.
Now, here's where I get into trouble... The custom UISlider and UISwitch examples I've found seem to rely on a track that's stationary with a movable knob/toggle. In the switch below, it would require a knob/track to animate behind a mask that also passes through touch events.
I've never been much of an interface coder, but this cute little bugger is just to awesome to leave alone. Can someone point me in the right direction?
I suggest just having the background stationary, and just fade between them? Sliding the track is probably not going to work so well, as you can still see the green/white around the edge of the knob.

animate images in cocos2d

I am newbie in cocos2D But have developed several view based application.
So what I want to know is:
Is there any alternate ,for animationImages used for animating the images in imageview, in cocos2D?
I want to use the same thing i.e: Animate the images same as any gif file.
Thanks in advance....
Animation in Cocos2D is handled by the CCAnimation class, you can read the documentation here:
http://www.cocos2d-iphone.org/api-ref/latest-stable/interface_c_c_animation.html
There are a number of examples for animating sprites, using a Sprite Sheet, single Images, a Texture Cache, etc.
This is one of my favorite ones:
http://www.raywenderlich.com/1271/how-to-use-animations-and-sprite-sheets-in-cocos2d

Draw a shadow behind UIWebView

I know similar questions have been asked before, so don't get snarky and link to previous answers. The reason I am repeating this is that none of the answers have worked.
I have a UIWebView, and I want to draw a pretty drop-shadow behind it. I have tried subclassing and using some CoreGraphics goodness in drawRect:, but to no avail. Can anyone point me in the right direction? Thanks.
You could place a UIImageView under the UIScrollView with a slight offset, and give the image view a shadowy-looking image.
In this case, it would be convenient to use the stretchableImageWithLeftCapWidth:topCapHeight: method of UIImage to get a shadow image that can have nicely blurred edges and corners without distorting if you alter its size.
I think the usual quartz shadows are hard to apply to a UIWebView since you don't really have access to the raw drawing code, which would be the best place to plug that in.
Addendum Here's a sample drop shadow image:
. It has 4 pixel cap size all around, for use with the above stretchableImage method, and an alpha of 80% (so it's 20% transparent in the middle, tapering out at the edges). Feel free to use it. They're easy to make with a selection + feathering in your favorite graphics app.