diff --git a/PWParallaxScrollView.xcodeproj/project.xcworkspace/xcshareddata/PWParallaxScrollView.xccheckout b/PWParallaxScrollView.xcodeproj/project.xcworkspace/xcshareddata/PWParallaxScrollView.xccheckout
index e7c1140..ed23ed2 100644
--- a/PWParallaxScrollView.xcodeproj/project.xcworkspace/xcshareddata/PWParallaxScrollView.xccheckout
+++ b/PWParallaxScrollView.xcodeproj/project.xcworkspace/xcshareddata/PWParallaxScrollView.xccheckout
@@ -10,29 +10,29 @@
PWParallaxScrollView
IDESourceControlProjectOriginsDictionary
- 0D02EFF2-E474-4994-9FFA-5E26408D6717
- https://github.com/wpsteak/PWParallaxScrollView.git
+ 3E183C459E55170D25FCA0466CE3115E287F8D92
+ github.com:iradicator/PWParallaxScrollView.git
IDESourceControlProjectPath
- PWParallaxScrollView.xcodeproj/project.xcworkspace
+ PWParallaxScrollView.xcodeproj
IDESourceControlProjectRelativeInstallPathDictionary
- 0D02EFF2-E474-4994-9FFA-5E26408D6717
+ 3E183C459E55170D25FCA0466CE3115E287F8D92
../..
IDESourceControlProjectURL
- https://github.com/wpsteak/PWParallaxScrollView.git
+ github.com:iradicator/PWParallaxScrollView.git
IDESourceControlProjectVersion
- 110
+ 111
IDESourceControlProjectWCCIdentifier
- 0D02EFF2-E474-4994-9FFA-5E26408D6717
+ 3E183C459E55170D25FCA0466CE3115E287F8D92
IDESourceControlProjectWCConfigurations
IDESourceControlRepositoryExtensionIdentifierKey
public.vcs.git
IDESourceControlWCCIdentifierKey
- 0D02EFF2-E474-4994-9FFA-5E26408D6717
+ 3E183C459E55170D25FCA0466CE3115E287F8D92
IDESourceControlWCCName
PWParallaxScrollView
diff --git a/PWParallaxScrollView/PWParallaxScrollView.h b/PWParallaxScrollView/PWParallaxScrollView.h
index 1f54672..74b9fca 100755
--- a/PWParallaxScrollView/PWParallaxScrollView.h
+++ b/PWParallaxScrollView/PWParallaxScrollView.h
@@ -19,6 +19,8 @@
@property (nonatomic, assign) UIEdgeInsets foregroundScreenEdgeInsets;
@property (nonatomic, assign) NSInteger maxAllowableItem;
+@property (nonatomic, assign) BOOL enabled;
+@property (nonatomic, assign) BOOL showsScrollIndicator;
- (void)prevItem;
- (void)nextItem;
@@ -43,6 +45,7 @@
- (void)parallaxScrollView:(PWParallaxScrollView *)scrollView didChangeIndex:(NSInteger)index;
- (void)parallaxScrollView:(PWParallaxScrollView *)scrollView didEndDeceleratingAtIndex:(NSInteger)index;
- (void)parallaxScrollView:(PWParallaxScrollView *)scrollView didRecieveTapAtIndex:(NSInteger)index;
+- (void)parallaxScrollView:(PWParallaxScrollView *)scrollView didEndScrollingAnimation:(NSInteger)index;
@end
diff --git a/PWParallaxScrollView/PWParallaxScrollView.m b/PWParallaxScrollView/PWParallaxScrollView.m
index c7c1538..e7ccf04 100755
--- a/PWParallaxScrollView/PWParallaxScrollView.m
+++ b/PWParallaxScrollView/PWParallaxScrollView.m
@@ -50,6 +50,13 @@ - (id)initWithFrame:(CGRect)frame
return self;
}
+-(void)setFrame:(CGRect)frame{
+ [super setFrame:frame];
+ _touchScrollView.frame = self.bounds;
+ _foregroundScrollView.frame = self.bounds;
+ _backgroundScrollView.frame = self.bounds;
+}
+
- (void)setDataSource:(id)dataSource
{
_dataSource = dataSource;
@@ -92,14 +99,18 @@ - (void)initControl
[self addSubview:_backgroundScrollView];
[self addSubview:_foregroundScrollView];
[self addSubview:_touchScrollView];
+
+ _enabled = YES;
}
#pragma mark - public method
- (void)moveToIndex:(NSInteger)index
{
- CGFloat newOffsetX = index * CGRectGetWidth(_touchScrollView.frame);
- [_touchScrollView scrollRectToVisible:CGRectMake(newOffsetX, 0, CGRectGetWidth(_touchScrollView.frame), CGRectGetHeight(_touchScrollView.frame)) animated:YES];
+ if (_enabled) {
+ CGFloat newOffsetX = index * CGRectGetWidth(_touchScrollView.frame);
+ [_touchScrollView scrollRectToVisible:CGRectMake(newOffsetX, 0, CGRectGetWidth(_touchScrollView.frame), CGRectGetHeight(_touchScrollView.frame)) animated:YES];
+ }
}
- (void)prevItem
@@ -144,6 +155,21 @@ - (void)reloadData
}
}
+- (void)setEnabled:(BOOL)enabled
+{
+ _enabled = enabled;
+ _touchScrollView.multipleTouchEnabled = enabled;
+ _touchScrollView.pagingEnabled = enabled;
+ _backgroundScrollView.pagingEnabled = enabled;
+ _touchScrollView.delegate = (enabled? self : nil);
+}
+
+- (void)setShowsScrollIndicator:(BOOL)showsScrollIndicator {
+ _touchScrollView.showsHorizontalScrollIndicator = showsScrollIndicator;
+ _foregroundScrollView.showsHorizontalScrollIndicator = showsScrollIndicator;
+ _backgroundScrollView.showsHorizontalScrollIndicator = showsScrollIndicator;
+}
+
#pragma mark - private method
- (void)touchScrollViewTapped:(id)sender
{
@@ -304,6 +330,13 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
}
}
+- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
+{
+ if([self.delegate respondsToSelector:@selector(parallaxScrollView:didEndScrollingAnimation:)]){
+ [self.delegate parallaxScrollView:self didEndScrollingAnimation:self.currentIndex];
+ }
+}
+
#pragma mark hitTest
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
@@ -316,7 +349,7 @@ - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
}
}
- return [super hitTest:point withEvent:event];
+ return (_enabled)? [super hitTest:point withEvent:event] : nil;
}
@end
diff --git a/PWParallaxScrollViewExample/ViewController.m b/PWParallaxScrollViewExample/ViewController.m
index 47ca527..11108ac 100755
--- a/PWParallaxScrollViewExample/ViewController.m
+++ b/PWParallaxScrollViewExample/ViewController.m
@@ -15,6 +15,8 @@ @interface ViewController ()
-
+
-
-
+
+
@@ -18,7 +18,6 @@
-
+
+
+
+
+
+
diff --git a/PWParallaxScrollViewExample/en.lproj/ViewController_iPhone.xib b/PWParallaxScrollViewExample/en.lproj/ViewController_iPhone.xib
index 4ae77f6..3915326 100755
--- a/PWParallaxScrollViewExample/en.lproj/ViewController_iPhone.xib
+++ b/PWParallaxScrollViewExample/en.lproj/ViewController_iPhone.xib
@@ -1,12 +1,13 @@
-
+
-
+
+
@@ -18,7 +19,6 @@
-
+
-
-
+
+
+
+
+