Skip to content

Instantly share code, notes, and snippets.

@xandrucea
Last active January 2, 2016 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xandrucea/8317488 to your computer and use it in GitHub Desktop.
Save xandrucea/8317488 to your computer and use it in GitHub Desktop.
Create ActionSheet for iOS 7 and iOS 8
--------------------------------------
// if( [[UIDevice currentDevice] systemVersion].doubleValue < 8.0 ){
UIActionSheet *actionSheet = [UIActionSheet new];
[actionSheet setTitle:prodAdFree.localizedTitle];
[actionSheet setDelegate:self];
[actionSheet setCancelButtonIndex:2];
[actionSheet addButtonWithTitle:NSLocalizedString(@"Produkt kaufen", @"")];
[actionSheet addButtonWithTitle:NSLocalizedString(@"Produkt wiederherstellen", @"")];
[actionSheet addButtonWithTitle:NSLocalizedString(@"Abbrechen", @"")];
[actionSheet showInView:self.mm_drawerController.view];
// } else if( [[UIDevice currentDevice] systemVersion].doubleValue >= 8.0 ){
//
//
// UIAlertController *alertSheet = [UIAlertController alertControllerWithTitle:prodAdFree.localizedTitle
// message:prodAdFree.localizedDescription
// preferredStyle:UIAlertControllerStyleActionSheet];
//
// UIAlertAction *purchase = [UIAlertAction actionWithTitle:NSLocalizedString(@"Produkt kaufen", @"")
// style:UIAlertActionStyleDestructive
// handler:^(UIAlertAction *action) {
// [self purchaseProduct:prodAdFree];
// }];
// UIAlertAction *rePurchase = [UIAlertAction actionWithTitle:NSLocalizedString(@"Produkt wiederherstellen", @"")
// style:UIAlertActionStyleDestructive
// handler:^(UIAlertAction *action) {
// [self rePurchaseProduct:prodAdFree];
// }];
// UIAlertAction *cancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"Abbrechen", @"")
// style:UIAlertActionStyleCancel
// handler:nil];
// [alertSheet addAction:purchase];
// [alertSheet addAction:rePurchase];
// [alertSheet addAction:cancel];
//
// [self.mm_drawerController presentViewController:alertSheet animated:YES completion:nil];
// }
Rotate and Scale UIImageView and change UIImage between scaling
// [self runRotation];
// [self.imageViewRank.layer addAnimation:scaleOut forKey:@"scaleOut"];
// [UIView animateWithDuration:2.0f animations:^{
//
//
// } completion:^(BOOL finished) {
//
// [UIView animateWithDuration:2.0 animations:^{
//
// [self.imageViewRank setImage:[UIImage imageNamed:@"badge13"]];
//
// } completion:^(BOOL finished) {
//
// runStop = YES;
// }];
// }];
// [self.imageViewRank setCenter:CGPointMake(240 - (self.imageViewRank.center.x - 240), self.imageViewRank.center.y)];
// scaleOut = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
// scaleOut.fromValue = @1.0; // Your from value (not obvious from the question)
// scaleOut.toValue = @0.2;
// scaleOut.duration = 1.0;
// scaleOut.delegate = self;
// scaleOut.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
//
// scaleIn = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
// scaleIn.fromValue = @0.2; // Your from value (not obvious from the question)
// scaleIn.toValue = @1.0;
// scaleIn.duration = 1.0;
// scaleIn.delegate = self;
// scaleIn.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
//
// rotate = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.x"];
// rotate.values = @[@0.0, @(-20 * M_PI / 180.0), @0.0];
// rotate.duration = 0.4f;
// rotate.delegate = self;
// rotate.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut],
// [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
//
// [self.imageViewRank.layer addAnimation:scaleOut forKey:@"scaleOut"];
// [self.imageViewRank.layer addAnimation:rotate forKey:@"rotation"];
// self.imageViewRank.transform = CGAffineTransformIdentity; // Set end value (animation won't apply the value to the model)
// [UIView animateWithDuration:2.0 animations:^{
//
// CGAffineTransform transformation = CGAffineTransformRotate(self.imageViewRank.transform, M_PI);
// [self.imageViewRank setTransform:CGAffineTransformRotate(self.imageViewRank.transform, M_PI)];
// [self.imageViewRank setTransform:transformation];
//
// [self.imageViewRank setTransform:CGAffineTransformMakeScale(0.1, 0.1)];
//
// } completion:^(BOOL finished) {
//
// [UIView animateWithDuration:2.0 animations:^{
//
// [self.imageViewRank setTransform:CGAffineTransformIdentity];
// } completion:^(BOOL finished) {
//
// [self.imageViewRank.layer remove];
// }];
//
// }];
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{
// if(stillScaling && ([self.imageViewRank.layer animationForKey:@"rotation"] == anim)){
//
// [self.imageViewRank.layer addAnimation:rotate forKey:@"rotation"];
// NSLog(@"roration started again");
// }
if([self.imageViewRank.layer animationForKey:@"scaleOut"] == anim){
[UIView animateWithDuration:0.5f animations:^{
[self.imageViewRank setImage:[UIImage imageNamed:@"badge13"]];
} completion:^(BOOL finished) {
[self.imageViewRank.layer addAnimation:scaleOut forKey:@"scaleIn"];
}];
NSLog(@"start scaling in");
}
if([self.imageViewRank.layer animationForKey:@"scaleIn"] == anim){
running = NO;
NSLog(@"stop rotating");
self.imageViewRank.transform = CGAffineTransformIdentity;
}
}
--------------------------------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment