Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
emiliakubokirschenbaum
8,816 PointsSwipe to Change Feature
The iOS module covers animation changes but I was wondering if there was a good resource in understanding the swipe gesture (ie in Mail where you can swipe to delete for find more options). StackOverflow generally requires a little more than the basics and I am looking to try to start from scratch.
3 Answers
Jason Woolard
11,563 PointsTo accomplish something like this I had made a custom UITableViewCell with two views: a top view and bottom view. For the top view I added all of the initial labels and text I wanted to appear on load, and for the bottom I simply split the cell into two, utilizing the right half with my custom buttons 'Delete and Reply'. I then went ahead and added in two UIGestureControls (one to swipe left sliding the top view over to show the bottom half of the bottomview) and the other to swipe right to slide the top view back over. I hope this gives you a better understanding of how such features can be accomplished.
Jason Woolard
11,563 Points-(IBAction)swipers:(UISwipeGestureRecognizer*)recognizer
{
if (recognizer.direction == UISwipeGestureRecognizerDirectionRight)
{
[UIView animateWithDuration:0.25f animations:^
{
if (topView != nil)
{
topView.frame = CGRectMake(0.0f, topView.frame.origin.y, topView.frame.size.width, topView.frame.size.height);
}
}];
}
else if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft)
{
[UIView animateWithDuration:0.25f animations:^
{
if (topView != nil)
{
topView.frame = CGRectMake(-170.0f, topView.frame.origin.y, topView.frame.size.width, topView.frame.size.height);
}
}];
}
}
Hope this helps.
Amit Bijlani
Treehouse Guest TeacherAs mentioned in my tweet. Here's a great article: http://www.teehanlax.com/blog/reproducing-the-ios-7-mail-apps-interface/
emiliakubokirschenbaum
8,816 Pointsemiliakubokirschenbaum
8,816 PointsDo you happen to have any code I can see? I think I understand what you're getting at I just want to be sure. Thanks!