Skip to content

Instantly share code, notes, and snippets.

@keicoder
Created February 13, 2014 05:32
Show Gist options
  • Save keicoder/8970248 to your computer and use it in GitHub Desktop.
Save keicoder/8970248 to your computer and use it in GitHub Desktop.
objective-c : make basic table view with custom background and jason data v.5
//make basic table view with custom background and jason data v.5
//Docking views
//DynamicSandwichViewController.m
@implementation DynamicSandwichViewController
{
//Docking views
UISnapBehavior* _snap;
BOOL _viewDocked;
}
- (void)handlePan:(UIPanGestureRecognizer*)gesture {
...
} else if (gesture.state == UIGestureRecognizerStateEnded && _draggingView) {
[self tryDockView:draggedView];
...
}
}
#pragma mark - tryDockView
- (void)tryDockView:(UIView *)view {
if (debug==1) {NSLog(@"Running %@ '%@'", self.class, NSStringFromSelector(_cmd));}
BOOL viewHasReachedDockLocation = view.frame.origin.y < 100.0;
if (viewHasReachedDockLocation) {
if (!_viewDocked) {
_snap = [[UISnapBehavior alloc] initWithItem:view
snapToPoint:self.view.center];
[_animator addBehavior:_snap];
[self setAlphaWhenViewDocked:view alpha:0.0];
_viewDocked = YES;
}
} else {
if (_viewDocked) {
[_animator removeBehavior:_snap];
[self setAlphaWhenViewDocked:view alpha:1.0];
_viewDocked = NO;
}
}
}
#pragma mark - setAlphaWhenViewDocked (현재 뷰가 창 상단에 docking되어 있는지 여부에 따른 다른 창의 알파값 변화)
- (void)setAlphaWhenViewDocked:(UIView*)view alpha:(CGFloat)alpha {
for (UIView* aView in _views) {
if (aView != view) {
aView.alpha = alpha; }
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment