Custom drag calendar in iOS - ios

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.

Related

Minimimtrackimage alignment issues in swift

I’m trying to create a waveform player similar to soundcloud, the minimum track image I set for the slider originally kept stretching to the slider button itself. I wanted it perfectly aligned with the maximumtrackimage so I users the code:
Image.ResizableImage(withCapInsets:UIEdgeInsets:0,0,0,0)
Screen shot
Which made the image stretch out past the slider button to the whole slider track itself, which is what I wanted but the problem is that the image is passing the slider track and I want it to resize from the beginning of the slider track to the end.
I can't quite remember what the SoundCloud interface looks like, but I seem to recall it's something like this:
I generated that effect easily without using any slider. In general it's probably best to do things the easy way, constructing your own interface rather than trying to bend some existing interface element (such as your slider) to some purpose for which it was never intended.
My interface consists of two image views, a red version of the sound "wave" with a black version laid on top of it. The "transition" from black to red is performed by sliding a layer mask sideways over the black version of the image view, thus revealing the red version which was hidden behind it.
So all you would have to do is coordinate the position of the layer mask with the position being played within the song. If you wanted to use this as a scrubber, you would just detect the user's finger within the image view and do the same thing.

iCarousel – Make all items selectable, not just centered one

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.

Draw animations dynamically (interactively) on MKMapView

I want to draw an animation over MKMapView. I want it to be something like a compass arrow, that follows (rotates) user's taps / swipes .
So the arrow goes from the center of the screen and is of a fixed length. I don't need the line to be coordinate-specific, but I need to keep the map interactions intact (i.e. still being able to pinch-zoom on the map).
I tried to do that via MKPolyline (creating and then destroying a line), but that does not work (and from the way I had to do that I feel like it won't work). I wonder what would be the best way to handle that? Quartz?
I would accept just an explanation (which kind of view overlay over what, which classes to use), no code is necessary (but if you have a working example that's so much better ))
I draw views like a map ruler not as subview from MkMapView. I put kMapView and my ruler view into a container view. This works for views which positions are fixed on screen, like on center of screen, and are not related to a geographical position.

Double ranged and moveable slider component in iOS

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

slider control similar to ipad default calendar app

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.

Resources