Created
October 21, 2011 06:49
-
-
Save thetron/1303255 to your computer and use it in GitHub Desktop.
SGWMScrollView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SGWMScrollView.h | |
// SmartGardenWateringMobile | |
// | |
// Created by Nicholas Bruning on 21/10/11. | |
// Copyright (c) 2011 Involved. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> | |
@interface SGWMScrollView : UIScrollView | |
@property (nonatomic) CGRect interactiveFrame; | |
-(id) initWithFrame:(CGRect)frame interactiveFrame:(CGRect)intFrame; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SGWMScrollView.m | |
// SmartGardenWateringMobile | |
// | |
// Created by Nicholas Bruning on 21/10/11. | |
// Copyright (c) 2011 Involved. All rights reserved. | |
// | |
#import "SGWMScrollView.h" | |
@implementation SGWMScrollView | |
@synthesize interactiveFrame; | |
-(id) initWithFrame:(CGRect)frame interactiveFrame:(CGRect)intFrame{ | |
self = [super initWithFrame:frame]; | |
if(self){ | |
self.clipsToBounds = NO; | |
interactiveFrame = intFrame; | |
interactiveFrame.origin.x -= frame.origin.x; | |
interactiveFrame.origin.y -= frame.origin.y; | |
} | |
return self; | |
} | |
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{ | |
CGRect pointTestFrame = interactiveFrame; | |
pointTestFrame.origin.x += self.contentOffset.x; | |
pointTestFrame.origin.y += self.contentOffset.y; | |
if(CGRectContainsPoint(pointTestFrame, point)){ | |
return YES; | |
} | |
return NO; | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGRect innerFrame = CGRectMake(20, 40, 280, 280); | |
CGRect outerFrame = CGRectMake(0, 40, 320, 280); | |
self.scrollView = [[SGWMScrollView alloc] initWithFrame:innerFrame interactiveFrame:outerFrame]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment