How can I change the UIActivityIndicatorView to set a custom image? - iphone

Well, I am looking for a way to change my spinner image and use a custom image
Any suggestion?

I have created a subclass of UIActivityIndicatorView that allows you to set a custom image.

You could simply use a UIImageView and add an animation that rotates the view's layer indefinitely. You can achieve this using CoreAnimation. There are plenty of tutorials for this out there.
If you wish to start and stop the animation you can create a simple subclass of UIImageView that adds and removes said animation.
Here's a link for the animation: Basic keyframe animation (rotation)

Related

Views: How to overlay?

I want to use a UIProgressView but I want the background to be an image to make things a bit more good looking. I'm not sure how to lay one over the other. It would be important for the background image to encompass the UIProgressView.
Any help appreciated.
You can simply create a UIImageView for your background image, then add a UIProgressView as a sub view.
You can do this in either Interface Builder or in code such as [myBackgroundImageView addSubView:myProgressView];
Obviously you will need to setup the correct frame for both to ensure they are in the correct position.
Check out addSubview: in the Apple reference.

iPhone: Drawing on a UIButton

This tutorial shows how to draw on a graphics context for the view using Quartz 2D:
http://www.techotopia.com/index.php/An_iPhone_Graphics_Drawing_Tutorial_using_Quartz_2D
But I want to draw on a UIButton, not on a view. How can I do that?
Thanks
Draw on UIView . Add the view as subview to your UIButton.
A button IS a UIView. It inherits from UIControl, which inherits from UIView.
So buttons have a drawRect method.
So you can do everything described in the article you linked on a button.
However, buttons are set up to do a lot of things for you, and overriding the drawRect method could make those things not work correctly.
Buttons normally draw a title and a rounded rectangle frame. You can turn that off by setting the button's type to custom.
Custom buttons will draw an image if you install one.
Buttons normally also either draw a highlight over their image, or have a second image to use for the highlighted state. If you want to implement drawRect, you'll need to handle drawing the highlighted state yourself.
In general, you want to avoid using drawRect and use some other technique to get the content you want into your views.
What, exactly, are you trying to do?

How do I get more control of UIImageView animation?

I'm trying to display a series of images in a animation where the duration between the images changes frame to frame. I can successfully animate images where the duration is the same. I've looked into subclassing UIImageView but it doesn't seem to allow you access anything that could be helpful.
I've also looked into subclassing UIView directly but it seems like I'd have to write a lot of the stuff that UIImageView already does for me.
Is there a way to do this with UIImageView? Or if I am going to have to build my own UIView animation can someone point me the right direction to get started? Thanks.
You could have many UIImageViews next to one another, each representing one image, and animate them inside a UIView or UIScrollView, depending on what exactly you need to do. Animations with the help of UIView are very straightforward to implement.

Can I use DrawRect on a UIImageView loaded from a NIB?

I've created a NIB file with some button controls on it, and as a background it has an ImageView which contains a PNG file loaded from my project.
What I want to do is to draw on top of the ImageView - imagine that my UI is a clockface and I want to draw the hands of the clock on top of the background image.
Is it the correct approach to try to subclass the UIImageView and use its DrawRect as when I use the DrawRect of the default view I don't see anything on the screen?
I'm a little lost as I'm finding this particular bit of the documentation hard to follow.
Thanks.
Create a new custom UIView (e.g. named HandsView) that sits on top of your background view (by adding it as a subview of the UIImageView). In the custom view, you can use the drawRect method. Make sure, you clear the context to transparent, so that the background image can be seen below the HandsView.
If you just want to draw turning hands, you can also try to use two fixed UIImageViews with the images of the hands and use the transform property to apply a rotation.

UITableView Animating UImageView

How do I animate a UIImageView from UITableview with the flying effect?
Without knowing what you mean by the 'flying effect', pretty much any animation is possible using CoreAnimation.
Grab the UIImageView instance's layer and animate it as you wish.
Info on CoreAnimation can be found here.