Fully Customize UIPIckerView? - iphone

Target: To give feel like casino scrollers.
Description: I want to make a scroller which will start automatically as i click any button... which scroll with maximum speed and slow down speed and stop after certain speed just like you must have seen in Casino scrolls.
I am not allowed to use UIPickerView
Can any one please guide me so that i can complete this task
Thanks

I know this is the heck solution.
If you want to scroll on button clickable (then you would be knowing which position to stop) so you can always use
selectRow:inComponent:animated:
Selects a row in a specified component of the picker view. so you can animate that scroll by selecting row on unwanted position and after some time(you can use timer once the timer is done) select the row at wanted position.

You could use a UIScrollView with a very large content size and a repeating pattern inside it. You'd probably need extra code to make it only come to a stop at appropriate points. To avoid ever hitting the end of the scroll view, you could jump back up by the length of the repeating pattern whenever you get a chance.

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:).

Continuously scrolling UI Unity

So I am working working on something in unity (2d game). I have a list of button (UI) on my scene and I want to implement a scrolling mechanism. What is the best way to go about it? Currently , I can scroll through horizontally because I have added a "scroll rect" to the the canvas holding the buttons as I start the game. However when I try to scroll back (horizontally, it goes beyond the Buttons. Is there a way to make the scrolling continuous such that as I scroll, from the first UI element when I get to the last one and I keep scrolling, it continues with the first element. or what should I do. please let me Know If i should clarify.
In the Scroll rect you can set the movement type. I don't think the kind of "infinite scroll" you are asking for is available.
For your case, I think that the Use Elastic or Clamped mode to force the content to remain within the bounds of the Scroll Rect should do the work.
In the case of the infinite scroll specifically needed, you would need to ask for that explicitely and show your attempt for more specific help.

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.

How to center a UIActivityIndicatorView along with text (UILabel)?

I've had this issue come up a couple times doing iPhone development now and have yet to find a good solution for it. What I'm looking for is this:
I want to show some text along with an icon and I want the overall display to be centered within its parent view. Specifically, in my current case, I'm looking to display a box that says "Reconnecting..." with a UIActivityIndicatorView to the left of the text.
Previously, I've just relied on the fact that I know exactly the dimensions of the text and activity indicator, so I can position things absolutely to appear centered. What I'm looking for is something more automatic.
Any ideas?
One of the UIKit additions to NSString will return the pixel size of the text if you give it the font that you're using on the UILabel. So then presumably the total size of the two things together in the layout you describe is:
the difference between label.frame.origin.x and activityIndicatorView.frame.origin.x; plus
the width of the text.
You can then either shuffle both the views appropriately or give them a common parent that's still a subview of the whole thing and shift that.
An activity indicator can be shown in a view just calling a single method.Please click here get SHKActivityIndicator class

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.