ios custom progress bar designing - ios

I want to create a custom progress bar for my app. I am new to iOS development and finding it difficult to understand codes on google which confuse me a lot. What I want is like growing animated progress bar.
e.g: like showing progress in terms of a tree growth from small plant(to a complete tree) which denotes the process completion.
Where and how to start? And also is Core Graphics or cocos2d which one will be apt for this?

If you're doing something graphical like a tree growing, do you already have the animation you want to use as a series of images?
If so, you could use a UIImageView. Whenever you want to update your progress bar, just check the progress of your task, and use that to work out which number image to display. So if you had twelve images, you could find the percentage complete of your task, divide by 100 then multiply by twelve (and then convert to an int) to get the image number you want.
Once you've done that, just get the appropriately named image and put it in your image view:
self.myImageView.image = [UIImage imageNamed:[NSString stringWithFormat:#"frame-%i", myImageNumber]];
As for when to do the progress check, that depends on the task you are doing. Some tasks have a natural place to inject a callback to update the UI, and for others it's better to just use a timer.

you cannot change much in uiprogressbar instead you can use UISlide to behave like progressbar
.
you can only change the frame of progressbar as:-
UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle
:UIProgressViewStyleBar];
[progressView setFrame:CGRectMake(0,0,320,10)];
you can create a uiSlider and make its ThumbImage to nil,setMinimumTrackImage ans maxtrackImage and then use the custom function on it to show the progress
custom UISlider

https://github.com/jdg/MBProgressHUD
Try this code its modst widely used open source code for your kind of purpose

Related

Customized UISlider with one more view

I need to create a subclass of UISlider in swift so that it has 3 bar views & 1 thumb image. Currently iOS Provides only 2 bar views & 1 thumb image.
The two bar views are minimumTrackImage & maximumTrackImage.
I need one more bar view on right hand side which is permissible limit of UISlider. i.e if slider has current value 50 max allowed value value is 100. I can able to set Permissible limit to 80 and slider will look like as below.
Could anyone please help...
Here is an example I quickly put together that hopefully shows what you need (see github-link below)....
Link to the example "permissibleLimitSlider" on GitHub
(The solution is done with Swift-3.1, Xcode-8.3.3 and iOS-Simulator-10.0)
The trick was:
A) to create a new maximumTrackImage (called "slider-track" in my example). I created that image in photoshop (but you can use a different graphics-program).
B) to add an IBAction (with Event "ValueChanged") from your Storyboard-Slider into the MyViewController. And in this method you simply observe the sender.value and limit it to 0.8
That's how it looks like in my github example:
Feel free to change colors by changing the Asses-images in the project!
Hope this static limit (of 0.8) is what you need. If you need a dynamic limit (settable in code), I suggest you provide something like 10 images, make the Slider a "discrete slider" and set your maximumTrackImage to one or the other image whenever you need to...
More examples on how to make your slider a discrete-slider can be found here
A very good tutorial on how to make custom-sliders can be found here

Animated Background

I am making an app in which there are two buttons in the center. The background is there and I need the background to have an animation. With that said I mean like little raindrops constantly falling in the background. I have no clue on how to do this. My customer really, really wants this. Thanks!
Make sure the images are named in numerical order with the number at the end of the name. Then drag and drop the file of images into your Xcode folder area. Then you reference only the image name and not the number in animatedImageNamed.
You need to create an ImageView the size of the Background for each device you plan on using.
//place this in your viewDidLoad
UIImageView * background = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 55)];
UIImage * image = [UIImage animatedImageNamed:#"MovingCar" duration:3.6];
background.image = image;
[self.view setBackgroundView: background];
You can change the duration to suit your needs accordingly.
You could use the UIView method animateWithDuration:animations: or one of it's variants that has a completion method to animate images from the top to the bottom of the screen. Take a look at the Xcode docs on that method, and search the web for examples.
As the other poster says, this site is for helping people with problems, not for asking others to provide you with ready-made solutions.
I could bang out some animation code for you that would create an endless stream of falling raindrops, but it would probably take me a couple of hours to get it fully working, and I'd have to charge you for it. (Plus I'm not very familiar with Swift so I'd have to do some translation from Objective-C, which is my day-to-day programming language.)

C4 stepper custom images

I'm trying to use my own images on a C4Stepper. I'm setting it up like this
#implementation C4WorkSpace{
C4Stepper *theStepper;
C4Image *stepperBackground;
C4Image *stepperPlus;
}
-(void)setup {
//load backgroundimage
stepperBackground=[C4Image imageNamed:#"icon_zoom.png"];
stepperBackground.width=100;
//load incrementImage
stepperPlus=[C4Image imageNamed:#"icon_zoom_plus.png"];
stepperPlus.width=stepperBackground.width/2;
//setup stepper
theStepper=[C4Stepper stepper];
[theStepper setBackgroundImage:stepperBackground forState:NORMAL];
[theStepper setIncrementImage:stepperPlus forState:NORMAL];
theStepper.center=self.canvas.center;
[self.canvas addSubview:theStepper];
}
The 2 icons look like this:
Strangely, what appears on the canvas looks something like this: !
Are there any special requirements for the zoomStepperImages? A certain size or something?
There are special requirements.
The background image used is "stretchable", so you have to design a button image that can be stretched if needed. If you have a look at any of the button images (incl. in the Media.xcassets folder) you'll see that they are generic. For example, the selected button background image looks like:
Similarly, the increment / decrement images are themselves independent of the background images. The incrementNormal image included in the same folder looks like:
You can see how the default values of the C4Stepper class are initialized in C4AppDelegate.m:
...
[C4Stepper defaultStyle].style = basicStyle;
[C4Stepper defaultStyle].tintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"lightGrayPattern"]];
[[C4Stepper defaultStyle] setDecrementImage:[C4Image imageNamed:#"decrementDisabled"] forState:DISABLED];
[[C4Stepper defaultStyle] setDecrementImage:[C4Image imageNamed:#"decrementNormal"] forState:NORMAL];
[[C4Stepper defaultStyle] setIncrementImage:[C4Image imageNamed:#"incrementDisabled"] forState:DISABLED];
[[C4Stepper defaultStyle] setIncrementImage:[C4Image imageNamed:#"incrementNormal"] forState:NORMAL];
So, what you want to do is create an image for your background (mine is stretchable because the stuff in the middle are straight lines that can be stretched horizontally without looking stretched. You also want to create independent + - images for increment / decrement sides of the button.
Just as a note, when I was creating the C4Button class, I had to play around with the various images I was creating to get them to "look" right... In the end, I had to do a lot of tweaking and experimenting to learn how they were rendered. The difficulty I had in figuring this out was that the rendering mechanism of UIButton itself was a bit strange and I had to learn how to fit things into the button so that they rendered properly.

Spin rate of UIActivityIndicatorView

What is the spin speed of a UIActivityIndicatorView? Specifically, how long does it take to complete one revolution?
UPDATE: the reason for asking this is that I want to create my own activity indicator spinner that's smaller than the normal one. But I can't change the size of the normal one, so I'm making my own via UIImageView's animation options. I want to be as close to the normal one in behavior, timing, feel, etc. as I can get.
The spin rate of the UIActivityIndicatorView is 1.0 as of iOS 6.1.4. This number is an implementation detail and is not guaranteed to remain at this value for future versions of iOS. You can figure this out by accessing the first subview of a UIActivityIndicatorView, which is a UIImageView, and querying its animationDuration property. It looks like UIActivityIndicatorView uses an animated UIImageView under the hood.

How to use UIActivityIndicator as a status indicator in real time for iOS?

]]I am trying to build a UIActivityIndicator for my iOS app so that it is displaying the current state of certain processes that are running, and each quarter segment of the wheel will be highlighted by a different colour, depending on the status.
All of the tutorials I have seen show how to build an activity indicator that spins while something is loading, whereas I need the indicator to remain on the screen and show state. I need the indicator to remain hollow, with only the circumference that is coloured. How would I do this?
Core graphics. You'll have to make a custom class that inherits from UIView and do all the drawing yourself. You'll probably override a setter for a float (progress), which will update the display (using [self setNeedsDisplay]. Then in the drawRect: method you'll use this class property of progress to determine what color and what angle to draw/fill in the view. Check out the source of MBProgressHud for some reference: MBProgressHUD

Resources