I need a UIImageView initialized with an image that rotates around its own axis in the same way it does in this
GIF example.
My task is actually a little more complicated because I also need to turn a flat image into a thick, coin-like 3D image, but I won't bother anyone here with that. The only thing I want to know right now is whether it's possible to animate a UIImage like the example above, and if so, then how do I do it?
Related
I'm trying to achieve a sort of dynamic UIView masking effect. Here is a sketch:
So as you can see, I'm trying to create a UIView that can effectively cut through an image to reveal the image behind it. I already know how to return an image with a mask statically, however I would like the "revealer" to be draggable (I'll use pan gesture) and live.
Does anyone have any ideas or starting points on how to achieve this? Thanks
(NOTE: My demo says White layer, but I'd actually like to show another image or photo).
masking an image is not that difficult.
This link shows the basics.
http://iosdevelopertips.com/cocoa/how-to-mask-an-image.html
But personally I think i would make 2 UIImage views and crop the content of the draggable UIView. I'm not sure but I would expect that clipping and panning the second image will be less computationally expensive then applying the mask and will get you a better frame rate.
So I would do: UIImageView of the full image. A UIView on top of it with a white and some transparency setting to make it look white, then a UIImageView with the image either places or cropped so that only the correct section is showing.
I want to draw a rectangular UIImage to a polygon UIImage.
Like below example.
to
you will have to look into OpenGL ES, this will definately be able to draw textures onto a plain surface which is tilted, and most likely its your only option
. plus, the advantage being, you can actually animate the tilt in motion, like on coverflow
im not sure quartz can do it, but you will have to check that.
How can a bounding box be created for a UIImageView that is not a CGRect?
I would like to have objects in my view which should display images as well as detection collisions.
The issue is I would like these object to be whatever shape they are rather than fitting them into a CGRect and detecting collisions on areas which are inside the box but are nit the actual image.
How does one achieve this?
This is a non-trivial problem. But the basics are a CGRect is a rectangle and a hit test inside of a rectangle is fairly easy to understand. However, you sound like you want a more complex shape. UIImageView displays an image. It does not have any idea about what shape you want to use for your collision test. So you are going to have to tell it.
One easy thing to do is to look at the alpha/transparent values of the display image to create a shape. So to answer the question is a point hitting an image we figure out the location of point in the image and return true if the alpha is greater than 0. If you do this you can create any image with a transparent background and the code will just work.
If that will not work for you then can can also run a hit test on a point and a polygon this post covers that in detail.
How can I determine whether a 2D Point is within a Polygon?
What would be the way to draw a triangular button on the iPhone. It would be nice if I could also change its parameters (backgroundcolor, font etc..) as with the regular buttons.
Ideally I would like equilateral triangles.
take a look at this post: http://iphonedevelopment.blogspot.com/2010/03/irregularly-shaped-uibuttons.html
You could transform you button/view using core animation 3d transform. I am not sure how it will look like inside of it. but you surely can get a triangle form view.
You can apply a rotation in 3D (arround X or Y axis, not Z) with a large enough angle that it looks like a triangle.
An alternative approach is to make it look like triangular. You probably not need it TO BE triangular. So, maybe by setting a triangular look like image or maybe by hiding part of the button with (2D) rotated view or layer.
If you are not changing too much the background images of your buttons, I suggest to put in the resources, some .png file you create using photoshop for example, in which the triangular part has full opacity and the remaining areas are full transparent.
Then create UIImage using the method : [UIImage imageNamed:file_path_inside_resources_folder] and set it as background image for your button.
Note that you need to do the work only once, since the UIButton will resize the picture according to its own frame dimensions.
Regards
Meir Assayag
I'm working in a view based application and am trying to find some code that will let me grab some pixel colors from one of my images and use it for collision detection against one of my UIImageViews but haven't had any luck finding anything on this subject. So if my UIImageView for my player collides with the UIImageView of my map && collides with the color black in my image that's placed inside of my map view... then run collision code... or something along those lines.
Is your question about getting the pixel color, or about doing collision detection?
If you want to get the pixel color, I'm not sure there's an easy way to do it - you may have to mess with your current graphics context to get it, and nothing is coming up in the docs.
If it's just collision detection you want to do, take a look at UIView's convertPoint:toView: and convertPoint:fromView: methods. They let you take defined points within a given view and get their equivalents in other views. With some basic math on the resultant points, you could theoretically do some pretty good collision detection without having to worry about pixel colors.