Skip to content

Commit

Permalink
iOS 5 animation bug fix via idevsoftware, retina support via planerde…
Browse files Browse the repository at this point in the history
…, removed subclass dependency
  • Loading branch information
SRandazzo committed Oct 29, 2011
1 parent e402524 commit 6afbdf3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
4 changes: 1 addition & 3 deletions OpenFlow/AFOpenFlowView.h
Expand Up @@ -28,12 +28,10 @@

#import "AFItemView.h"

#import "PPScrollView.h"

@protocol AFOpenFlowViewDataSource;
@protocol AFOpenFlowViewDelegate;

@interface AFOpenFlowView : PPScrollView <UIScrollViewDelegate> {
@interface AFOpenFlowView : UIScrollView <UIScrollViewDelegate> {
id <AFOpenFlowViewDataSource> dataSource;
id <AFOpenFlowViewDelegate> viewDelegate;

Expand Down
42 changes: 32 additions & 10 deletions OpenFlow/AFOpenFlowView.m
Expand Up @@ -58,13 +58,12 @@ - (SBNotifyingWindow *)appWindow
}

- (void)setUpInitialState {

[[self appWindow] addObjectInterestedInTouches:self];

[self setBackgroundColor:[UIColor clearColor]];
// Set up the default image for the coverflow.
self.defaultImage = [self.dataSource defaultImage];
// Create data holders for onscreen & offscreen covers & UIImage objects.
coverImages = [[NSMutableDictionary alloc] init];
coverImageHeights = [[NSMutableDictionary alloc] init];
Expand All @@ -75,14 +74,15 @@ - (void)setUpInitialState {
// Initialize the visible and selected cover range.
lowerVisibleCover = upperVisibleCover = -1;
selectedCoverView = nil;
// Set up the cover's left & right transforms.
leftTransform = CATransform3DIdentity;
leftTransform = CATransform3DTranslate(CATransform3DIdentity, 0, 0, SIDE_COVER_ZPOSITION / 2.0);
CGFloat sideCoverAngle = [AFOpenFlowGeometry sideCoverAngle];
leftTransform = CATransform3DRotate(leftTransform, sideCoverAngle, 0.0f, 1.0f, 0.0f);
rightTransform = CATransform3DIdentity;

rightTransform = CATransform3DTranslate(CATransform3DIdentity, 0, 0, SIDE_COVER_ZPOSITION / 2.0);
rightTransform = CATransform3DRotate(rightTransform, sideCoverAngle, 0.0f, -1.0f, 0.0f);
self.scrollEnabled = YES;
self.userInteractionEnabled = YES;
self.showsVerticalScrollIndicator = NO;
Expand All @@ -109,7 +109,6 @@ - (void)setUpInitialState {
selectedCoverCaption.font = [UIFont systemFontOfSize:CAPTION_FONTSIZE];

[self addSubview:selectedCoverCaption];

}

- (AFItemView *)coverForIndex:(int)coverIndex {
Expand Down Expand Up @@ -147,7 +146,7 @@ - (AFItemView *)dequeueReusableCover {
- (void)layoutCover:(AFItemView *)aCover selectedCover:(int)selectedIndex animated:(Boolean)animated {
int coverNumber = aCover.number;
CATransform3D newTransform;
CGFloat newZPosition = [AFOpenFlowGeometry sideCoverZPosition];
CGFloat newZPosition = [AFOpenFlowGeometry sideCoverZPosition]/2;
CGPoint newPosition;


Expand All @@ -173,8 +172,31 @@ - (void)layoutCover:(AFItemView *)aCover selectedCover:(int)selectedIndex animat
}

aCover.layer.transform = newTransform;
aCover.layer.zPosition = newZPosition;
aCover.layer.position = newPosition;
//aCover.layer.zPosition = newZPosition;

if([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0 && animated) {

CABasicAnimation *zPositionAnimation = [CABasicAnimation animationWithKeyPath:@"zPosition"];

[zPositionAnimation setToValue:[NSNumber numberWithFloat:newZPosition]];

[zPositionAnimation setDuration:.3];

[zPositionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];

[zPositionAnimation setRemovedOnCompletion:NO];

[zPositionAnimation setFillMode:kCAFillModeForwards];

[aCover.layer addAnimation:zPositionAnimation forKey:nil];

} else {

aCover.layer.zPosition = newZPosition;

}

aCover.layer.position = newPosition;

if (animated) {
[UIView commitAnimations];
Expand Down
2 changes: 1 addition & 1 deletion OpenFlow/AFUIImageReflection.m
Expand Up @@ -74,7 +74,7 @@ - (UIImage *)addImageReflection:(CGFloat)reflectionFraction {

CGSize size = CGSizeMake(self.size.width, self.size.height + reflectionHeight);

UIGraphicsBeginImageContext(size);
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);

[self drawAtPoint:CGPointZero];
CGContextRef context = UIGraphicsGetCurrentContext();
Expand Down

0 comments on commit 6afbdf3

Please sign in to comment.