Using a progress bar as a seek bar - iphone

How can a progress bar be used as a seek bar?

You want to use an UISlider. Update its position periodically according to the playing position. Adjust your playing position whenever the slider calls its action.

You should build a custom control for that.
There are tools to make this extremely easy. I don't want to do advertisement, but have a look at Opacity. There you can create vector drawings with paramters like one for the current progress value. And you can have this drawing exported as source code which will create a UIView or UIControl subclass (at your choice) that has a property to set the current progress.
At least that's the way I'd do this.

Related

Swift: Custom Slider (Slide To Unlock style)

I am trying to implement a slider in the known slide to unlock style from older iphones to perform an action inside my swift app. The Slider should change background color and change the text inside while dragging. When the user drags til the end, the thumbView should stick to the right side and wait for a confirmation (some event) coming in to finally present a new view.
The slider should look something like this:
First state
Second state while dragging
Third state after releasing
I have found a few things on the internet but nothing that comes close to what I want to do. How would I go about doing this? My guess would be a combination of views with drag events but I feel like there must be an easier way. Any Ideas?
Maybe a UISlider with a transparent track on a rectangle view with your text and color. You can set your image as the UISlider's thumb and receive events as the value changes and when the user touches and releases it.
You can use that to for example, animate the thumb back to the start when the user releases on any place except the end of the track. Also, you can set the slider's value from 0 to 1 and use it to calculate the color, so it changes smoothly.
When the user releases on the end of the track, you activate the activity indicator and start your process to present the next view....
Even though this is a possibility, I think I'd try doing a custom control using a pan gesture. It'd give you more control and you could for example choose how the thumb image animates when going back to the start on release.... I dont' think you can do that with UISlider's setValue(animated:).

Create a UIScrollView that can be embedded into another view

I'm trying to build a custom, reusable UIScrollView that can be added to multiple views. The scroll view is going to be a weight picker. For the life of me, I can't find a decent example for how to implement this neatly or cleanly.
I would love for someone to point me to an existing library or tutorial that shows me how to do this. I've hacked apart a few examples, but so far, nothing is very good or reusable. Please help!!
For what it's worth, I have an image that individual ticks for the weight. So I can select to the tenth of the number (e.g. 160.4). The image has the first tick bold and larger than the remaining 9. I'd like to have the weight/number centered over the large tick. I'll update the points to my label/datasource after scrolling stops.
UPDATE
I need to make this. I have the custom font, background, and ticker image.
I would not do this through an UIScrollView. I think it would be more complex and you would certainly end up having issues when trying to add you custom picker into another scroll view.
What I would do is:
building the picker view by means of a series of CALayers, each one representing a "building block" of your picker view; see attached image:
each building block would represent a specific value by mixing a UILabel (the text) and an image;
use a pan gesture recognizer, or alternatively define touchesBegin/Moved/Ended method to deal with panning;
when a pan is done, you displace the view content to the left or right according to the panning;
when panning, you also add new building blocks to the left or right end of the picker to account for empty areas that would be revealed by the displacement done at point 4.
I think that having a look at another kind of custom control source code would be of great help to you. You would not possibly find your custom picker already implemented, but could get some guidance. Have a look then at cocoa controls.
Hope this helps.
If I were going to implement this, I would create a really wide image that had every weight on it I'd ever need - I would probably create this in code when the app started up. This image is then used as the contentView of your picker. You get all the scrolling features "for free", and you could even update the values shown in the other parts of the view during scrolling (or dragging.
The scrollView is just the area with the tick marks and weight numbers, and resides in a subview above the background, but below the centered vertical line that shows the actual weight.
EDIT: on second thought, forget the image. If you have the code to draw the image, you can do the drawing in a custom UIView. So you get the draw rect, you know the contentOffset, so you can draw just what you need.

progress circle UIControll iPhone

Anybody know how to make progress indicator of doing something like on a screenshot?
There are mainly two way to do this:
Create and save many images with the progress indicator in various positions. Then use UIImageView to display it, changing the image accordingly to the current progress. This is a easy solution, however it requires you to create (manually) the various images. Besides it's not continuos (even if it can be smooth enough, according to the number of images you save). However, it can give a good effect (according to your needs).
Draw the indicator at runtime. In your case it should not be so hard since your progress indicator is very simple. Take a look at CGContext, it will provide all the method to draw a circle, draw lines and fill a path with a color. This will give a better result than the previous solution, however it requires the indicator to be redrawn every time.
Check out TKAProgressCircleView. Does exactly what you need, I use it myself in couple of apps.

How can I make an iPhone UIView "pulse" or fade from one color to another repeatedly?

I want a UIView with a glowing or pulsing effect, like the status bar during a call on the iPhone. Does anyone know how I would go about doing this? I've experimented with NSTimer but can't seem to find how to go about this.
Thanks!
The animation API has the ability to message a callback you provide when the animation completes. You can use the API to daisy-chain together a series of animations from one state to another, giving the pulse effect you are looking for.

UIScrollView carousel menu

I'm trying to figure out if I can get what I want out of UIScrollView through some trickery or whether I need to roll my own scroll view
I have a series of items in row that I want to scroll through. One item should always be centered in the view, but other items should be visible to either side. In other words, I want normal scrolling and edge bouncing, but I want the deceleration when the user ends a touch to naturally settle at some specified stop point. (Actually now that I think of it, this behavior is similar to coverflow in this respect.)
Take a look at this project: SwipeView
Good luck
I'd check out https://github.com/nicklockwood/iCarousel, it's awesome.
You should take a look at the "pageingEnabled" property of a UIScrollView. Basically you can define a size of a segment and the number of segments. Then it will automatically stop to adjust to that specific segment like you want. If you set the segments to be smaller than the actual width of the screen I think you should get the behaviour you are looking for.