I would like to know how to implement the slider similar to the one in the Ipad default calendar application. I have attached the image below
If you see at the bottom, it acts like a slider which allows us to select any month either by just pressing it or sliding to it.
It would be great if anyone could tell me the name of that control. I tried using UISlider but I see that it allows only 3 options:
setThumbImage
setMinimumTrackImage
setMaximumTrackImage
If that control is indeed a slider control, could anyone tell me how I would be able to insert multiple images/ text
Thanks
It may be more complex than you'd like, but you could make your own:
Make a background that has UILabels for the dates
Make a selection box
In the UIViewController you could put something such as:
touchesMoved -
Make the selection box's x value equal to the touch
touchesEnded -
Make the selection box's x value equal to the touch's last x value
The touches moved would allow dragging of the selection box, and the touchesEnded would allow tap selection.
Then you would simply animate the selection box to the x value.
(This is an extremely simplified version, but you could do this pretty easily.)
This can be achieved by using UIScrollView. Add UIButtons programmatically having background images and text as well on them as per your requirement.
You can refer tutorial1 tutorial2 in which on screen only 1 page(Image) is displayed. You need to do some calculation for applying same logic to fit your requirement. i.e. Your scrollview will be smaller(in height) and bigger(in width) as displayed in image, you will be adding UIButtons in spite of images and most important at a time displaying more than 1 item but it won't be difficult. The Main part is only programmatically scrolling.
Related
Wondering if the above can be created using UISlider? If not, what other ways can this be accomplished?
You can set components of a UISlider, such as the currentThumbImage ( see: "Appearance of Sliders"1).
However, it is almost certainly easier to just re-implement a slider for this much customization. Simply use background UIImageView with the scale image, and then add a separate UIView (or UIImageView) for the arrow. Finally, attach a UIPanGestureRecognizer to the arrow view to allow a user translate the view vertically.
You can change a lot in the appearance of a UISlider like setting the thumb to a red arrow. You can also replace the background image with the inches ruler and with different rulers for the different device types and display sizes.
The one thing that I don't see is that you turn the slider to work vertically. I know them only working left to right.
If I'm right, your only chance is to have a ruler as background image and a view that contains the arrow and a label with the actual value. That whole view can be pawned and tapped using Gesture Listener.
I wanted to know how I could implement a custom calendar that looks like this: https://dribbble.com/shots/843863-Date-Filter/attachments/88756 in iOS. The user would be able to drag the dates in order to selected or deselect them. I'm a still a bit new to iOS development so I need some pointers on where to start looking for possible solutions. Thanks.
In your view controller, get the location of the touch in touchesBegan, and figure out the day from that touch. Then do the same thing in touchesEnded. Use the two dates as the boundaries of the date range, and voilà, that's it. If you want to animate the date range as the user drags their finger, then do the same thing in touchesMoved as well.
For the blue bar showing the date range, you could use blue left and right half-circle images for the ends of the rows, a blue rectangle for the middle of the row, and change all the buttons in the date range (except the boundary dates) to have no background image or foreground image, and turn the text color white. The boundary date views just get new background images.
In general, if you have anything that is in a grid, then you can figure out screen coordinates to grid coordinates (or vice versa) easily with a bit of math. Also, if there are some fancy graphics you want to make, break the whole thing into smaller parts that go with the views currently on the screen, and use your current views as "anchors" for where to put new views.
I have made numerous controls like pickers that had static elements. You could scroll it and pick the number like in standard picker.
But now I need to make a picker that changes its elements based on their position. Here is the image:
I want elements to shift color from white to another color slowly while they are being swiped, and change the size while they are moving. E.G. the central element will be filling with white and getting smaller size and next element should increase in size and fill with other color.
It should also be dynamic, if I go halfway and decide to swipe back, it should work as intended, returning the last central element to its position. So for each pixel I scroll the elements should change.
How do I attack this?
I know the basics, how to call delegate methods, I have this handled, only question is how do I animate this?
I managed to do this with scrollViewDidScroll delegate method, as it gets triggered even if the scroll view was moved 1 pixel.
I set up collection view with cells, and have it send scrollViewDidScroll to each of those cells. Based on the data those cells adjust themselves via CGAffineTransform (for size) and my own written functions that provide relevant color for each offset.
I'm using the great iOS control iCarousel's Wheel type and I want all of the buttons it contains to be usable / selectable at any time (i.e. I can tap any of them, no matter which one is currently at the top of the wheel). The user can still scroll the wheel as normal, but no matter which button they tap, it should register.
The current behavior seems inconsistent: if I tap one of the buttons directly next to the center one (to its left or right), that button moves into the center slot. Clicking one of the buttons two positions away 'sometimes' causes it to scroll to that letter, sometimes it's ignored. Any other buttons are always ignored.
Is this possible to set up, preferably without hugely modifying the class? I'm by no means an expert, but am learning every day :)
Thanks in advance.
Set carousel.centerItemWhenSelected = NO;
That will disable the behaviour where buttons other than the centre one are scrolled to the centre when you tap them.
As for the reason why some are not responding to taps at all, it is most likely because the frame of your carousel view is too small and the tap events are outside of the frame.
If you set carousel.clipsToBounds = YES; it will crop the carousel views to the frame as well so you'll be able to see exactly what size your carousel actually is.
I want to implement a slider-like component like the one at the bottom of this screenshot taken from Roambi. For those who haven't used Roambi, this slider is double ranged, i.e. you can define the ranges from the blue bars at the two ends. And then to indicate which data region you're interested, you move the grey area in between these blue bars to the left/right.
To implement this, two things come to my mind:
The left and right blue bars are UIViews. I handle touch events on these views to define the range. The middle area in between these two bars is also a UIView. I handle touch events on this view to move it left/right in order to define the data region.
I can implement a double ranged UISlider in order to get the functionality of the blue bars. (I already learned how to do this.) But then I don't know how to move the body of the slider to define the data range. Is this possible?
Also, could there be another way of implementing this?
You might find these projets interesting:
iosrangeslider
Wicked iOS Range Slider: Part Two
CMRangeSlider
A custom iOS control that gives you a UISlider like UI for selecting a range of values.
https://github.com/muZZkat/NMRangeSlider