Just a quick, shameless, plug for my first Cocoapod: TFSliderView. I needed to make an animated toggle switch that I could use in a number of locations for an in-house project my dev shop is working on, so I decided to make it into a Cocoapod and share it in case anyone else needed something similar.
It’s built off of POP (Facebook’s animation framework) and, all in all, is pretty simple to use. You can install it with Cocoapods using the following line:
pod "TFSliderView", "~> 0.1.0"
And then you just create a view programmatically (as shown below), and call the toggle delegate methods to do whatever it is you need to when the view toggles:
//Creating a frame for the slider that spans the width of the screen
CGRect frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 65.0f);
/*!Initializing the slider with a border color that matches the toggle color and left/right button images.
You can also set the animation constants here to change the amount of spring and bounce that occurs as the
TFSliderView *slider = [[TFSliderView alloc] initWithFrame:frame
/*!Overriding the default inverted images. If not overridden with something custom, the slider will
automatically invert the image colors as it toggles*/
slider.invertedLeftImage = [UIImage imageNamed:@"comment"];
slider.invertedRightImage = [UIImage imageNamed:@"outline-heart"];
//Setting the delegate
slider.delegate = self;
//Adding the slider to the View Controller's view
#pragma mark - Slider Delegates
- (void)sliderViewDidToggleRightOption:(TFSliderView *)sliderView
I still have a list of to-dos I want to get done to make the pod more useful, including the below, but I wanted to share what I have so far.
- Support for up to four buttons.
- More convenient init methods to accompany the one monster of a designated initializer.
- Generic starting values for
- Allowing each toggle state to have a unique color.
- Complete documentation.