LTShakeAndDeleteView
What is it ?
LTShakeAndDeleteView is an UIView that will allow you to shake it (and all its children) just the way the iOS home icons does when you want to delete or move them.
It allows also to add or remove an icon on the top left or top right position of your UIView to be able to handle that kind of action request.
There's 2 different kind of icons (minus or remove), of two different sizes (24x24 or 32x32) that can be placed at the left or right top position of the view.  How to add it in my project ?
Open your project into xCode, then create a new group named whatever you want, and drag/drop the following files onto it :
LTShakeAndDeleteView.h
LTShakeAndDeleteView.m
btMinus_24x24.png
btMinus_32x32.png
btRemove_24x24.png
btRemove_32x32.png
By doing that, you've added a new UIView style on your project. Now you're able to shake any UIView and to add on it or not a minus or Remove button able to warm you on a touch.
To do so, add an UIView on your xib and change its class to LTShakeAndDeleteView.
Now create an outlet connector on your .h project by adding it in your declarations :
IBOutlet LTShakeAndDeleteView *view1;
IBOutlet LTShakeAndDeleteView *view2;
IBOutlet LTShakeAndDeleteView *view3;
IBOutlet LTShakeAndDeleteView *view4;
Then connect it through Interface Builder.
Now, you're able to start shaking it or to stop it in this very easy way :
[view1 startShaking];
[view1 stopShaking];
How does the delete button work ?
The delete button can be shown by calling this method :
[view1 showDeleteButtonOfStyle:sdvMinus24
toLeftPosition:YES
forSelector:@selector(closeButtonTouched:)
ofParent:self
withTag:1];
The style of the button can be defined by the first parameter of this method. It can be one of the following ENUM values :
sdvMinus24
sdvMinus32
sdvRemove24
sdvRemove32
toLeftPosition can contain YES or NO to tell the method where you want to place the button.
forSelector must point to a selector to a method of your controller that will received the button touch action call. This must be a void method that is able to receive an (id) sender like this :
- (void)closeButtonTouched:(id)sender
ofParent must be the parent of this selector
withTag is an NSInteger value of your that can be retrieve into your returning method to identify which button of which view has been touched.
To hide the close button, just call :
[view1 hideDeleteButton];
Note that showing or hidding a button is done by using a smooth fade :-)
Method list
- (void)startShaking; Tell the component to start shaking the UIView, the optional close button and all childs of this View.
- (void)stopShaking; Well, hem, stop shaking ?
- (void)showDeleteButtonOfStyle:(SDVButtonStyle)style toLeftPosition:(BOOL)leftPosition forSelector:(SEL)selector ofParent:(id)parent withTag:(NSInteger)tag; As explained in the previous chapter, this is the method to be called to set a button style, a position, a returning method and to show it.
- (void)hideDeleteButton; Hide the button, using a smooth fade.
Very useful. Nice demo, easy to understand
It helped me a lot! Very well done! I recommend!
This component was easy to integrate and worked within minutes. Very easy to extend too.
The shaking algorithm is very close to the one in iOS.
Questions & Comments