Reputation: 17920
I have an animation to add a subview to make it appear as if it comes from inside where the user touches and then fills the entire screen.
Sameway, when an iOS app opens up from the place the user touches it..
- (void) showView : (UIView *) theview : (CGPoint) thepoint {
CGPoint c = thepoint;
CGFloat tx = c.x - floorf(theview.center.x) + 10;
CGFloat ty = c.y - floorf(theview.center.y) + 100;
[UIView animateWithDuration:0.5
delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^{
// Transforms
CGAffineTransform t = CGAffineTransformMakeTranslation(tx, ty);
t = CGAffineTransformScale(t, 0.1, 0.1);
theview.transform = t;
theview.layer.masksToBounds = YES;
[theview setTransform:CGAffineTransformIdentity];
}
completion:^(BOOL finished) {
}];
}
The above code did, what we needed till iOS8.. Built under XCode5.1 (iOS7 SDK)
But the behaviour was entirely different starting with the iOS8 SDK, XCode6
The ZOOM now is behaving strangely. I was finally able to find that CGAffineTransformIdentity
is behaving wrongly(or I use it wrongly?) in iOS8..
I see many have this issue, but they mentioned about AutoLayout. All my views are created programatically. We don't use a nib file.(IB)
How can I make this work with XCode 6?
Upvotes: 2
Views: 1339
Reputation: 17920
After couple of hours effort, I came up with a solution. I just post it for future users.
- (void) showView : (UIView *) theview : (CGPoint) thepoint {
CGPoint c = thepoint;
CGFloat tx = c.x - (floorf(theview.center.x)) ;
CGFloat ty = c.y - (floorf(theview.center.y));
/* The transformation now is before the animation block */
CGAffineTransform t = CGAffineTransformMakeTranslation(tx, ty);
t = CGAffineTransformScale(t, 0.1, 0.1);
theview.transform = t;
theview.layer.masksToBounds = YES;
/* Animate only the CGAffineTransformIdentity */
[UIView animateWithDuration:0.8
delay:0.0
options:UIViewAnimationOptionCurveEaseIn
animations:^{
theview.layer.masksToBounds = YES;
[theview setTransform:CGAffineTransformIdentity];
}
completion:^(BOOL finished) {
}];
}
But I have no clue, why it worked with iOS7 SDK previously and not with the new iOS8 SDK.!
Upvotes: 2