Skip to content

Instantly share code, notes, and snippets.

View almostintuitive's full-sized avatar

Mark Aron Szulyovszky almostintuitive

View GitHub Profile
@almostintuitive
almostintuitive / SVGView.h
Created June 8, 2014 15:51
SVGView for iOS (using UIWebView)
//
// SVGView.h
// Just call the loadSVG method with the SVG's NSData to display it with transparent background & scrollbars.
//
// github.com/itchingpixels.
//
#import <UIKit/UIKit.h>
@interface SVGView : UIWebView <UIWebViewDelegate>
@almostintuitive
almostintuitive / SwipeToPeepCell-1.m
Last active August 29, 2015 14:05
SwipeToPeepCell-1.m
if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
[self.delegate swipeableCellDidStartSwiping:self];
} else if (gestureRecognizer.state == UIGestureRecognizerStateChanged) {
[self.delegate swipeableCell:self didSwipeWithHorizontalPosition:touchLocation.x progress:progress];
} else if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
if (progress >= 0.7) {
[self.delegate swipeableCellCompletedSwiping:self];
} else {
[self.delegate swipeableCellCancelledSwiping:self];
}
@almostintuitive
almostintuitive / ViewController-1.m
Last active August 29, 2015 14:05
ViewController-1.m
- (void)adjustViewBasedOnSwipeProgress:(float)progress {
self.postWebView.center = CGPointMake(self.view.center.x+(self.view.bounds.size.width*progress), self.view.center.y);
}
@almostintuitive
almostintuitive / SwipeToPeepCell-2.m
Created August 30, 2014 13:16
SwipeToPeepCell-2.m
else if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
if (progress >= 0.7 || touchVelocity.x < -300) {
[self.delegate swipeableCellCompletedSwiping:self];
} else {
[self.delegate swipeableCellCancelledSwiping:self];
}
}
@almostintuitive
almostintuitive / ViewController-2.m
Created August 30, 2014 13:19
ViewController-2.m
- (void)adjustViewBasedOnSwipeProgress:(float)progress {
self.tableView.center = CGPointMake(self.view.center.x-(self.view.bounds.size.width*(1-progress)), self.view.center.y);
self.postWebView.center = CGPointMake(self.view.center.x+(self.view.bounds.size.width*progress), self.view.center.y);
}
@almostintuitive
almostintuitive / ViewController-3.m
Created August 30, 2014 13:20
ViewController-3.m
- (void)adjustViewBasedOnSwipeProgress:(float)progress {
self.tableView.alpha = progress;
self.tableView.center = CGPointMake(self.view.center.x*progress, self.view.center.y);
self.postWebView.center = CGPointMake(self.view.center.x+(self.view.bounds.size.width*progress), self.view.center.y);
}
@almostintuitive
almostintuitive / SwipeToPeepCell-3.m
Created August 30, 2014 13:21
SwipeToPeepCell-3.m
- (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer {
if ([gestureRecognizer class] == [UIPanGestureRecognizer class]) {
CGPoint velocity = [gestureRecognizer velocityInView:nil];
if (fabsf(velocity.x) > fabsf(velocity.y) ) {
return YES;
}
return NO;
}
return YES;
}
@almostintuitive
almostintuitive / ViewController-4.m
Created August 30, 2014 13:21
ViewController-4.m
- (void)swipeableCell:(SwipeToPeepCell *)cell didSwipeWithHorizontalPosition:(CGFloat)horizontalPosition progress:(float)progress {
self.tableView.scrollEnabled = NO;
[self adjustViewBasedOnSwipeProgress:(1-progress)];
}
@almostintuitive
almostintuitive / SwipeToPeepCell-4.m
Created August 30, 2014 13:22
SwipeToPeepCell-4.m
if (velocity.x > 0) {
return NO;
}
@almostintuitive
almostintuitive / ViewController-5.m
Created August 30, 2014 13:23
ViewController-5.m
- (void)adjustViewBasedOnSwipeProgress:(float)progress {
self.tableView.spring.alpha = progress;
self.tableView.spring.center = CGPointMake(self.view.center.x*progress, self.view.center.y);
self.postWebView.spring.center = CGPointMake(self.view.center.x+(self.view.bounds.size.width*progress), self.view.center.y);
}