Guest User

Untitled

a guest
Jun 13th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. - (void)willPresentActionSheet:(UIActionSheet *)actionSheet {
  2.  
  3. [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:YES];
  4. inShop = YES;
  5. int i = 0;
  6. for (UIButton *view in actionSheet.subviews)
  7. {
  8. if (i == 1)
  9. {
  10. CGRect cropRect = CGRectMake(20*4, 0, 20, 20);
  11. CGImageRef imageRefA = [UIImage imageWithData:[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"small_icons" ofType:@"png"]]].CGImage;
  12. CGImageRef imageRef = CGImageCreateWithImageInRect(imageRefA, cropRect);
  13. UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageWithCGImage:imageRef]];
  14. CGRect frame = [view frame];
  15. frame.size.width = 20;
  16. frame.size.height = 20;
  17. frame.origin.y = frame.origin.y + 12;
  18. frame.origin.x += 4;
  19. [imgView setFrame:frame];
  20. [actionSheet addSubview: imgView];
  21. //CGImageRelease(imageRefA);
  22. CGImageRelease(imageRef);
  23. [imgView release];
  24. }
  25. if (i == 2)
  26. {
  27.  
  28. CGRect cropRect = CGRectMake(20*1, 0, 20, 20);
  29. CGImageRef imageRefA = [UIImage imageWithData:[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"small_icons" ofType:@"png"]]].CGImage;
  30. CGImageRef imageRef = CGImageCreateWithImageInRect(imageRefA, cropRect);
  31. UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageWithCGImage:imageRef]];
  32. CGRect frame = [view frame];
  33. frame.size.width = 20;
  34. frame.size.height = 20;
  35. frame.origin.y = frame.origin.y + 12;
  36. frame.origin.x += 4;
  37. [imgView setFrame:frame];
  38. //CGImageRelease(imageRefA);
  39. CGImageRelease(imageRef);
  40. [actionSheet addSubview: imgView];
  41. [imgView release];
  42.  
  43. }
  44. if (i == 3)
  45. {
  46. CGRect cropRect = CGRectMake(20*3, 0, 20, 20);
  47. CGImageRef imageRefA = [UIImage imageWithData:[NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"small_icons" ofType:@"png"]]].CGImage;
  48. CGImageRef imageRef = CGImageCreateWithImageInRect(imageRefA, cropRect);
  49. UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageWithCGImage:imageRef]];
  50. CGRect frame = [view frame];
  51. frame.size.width = 20;
  52. frame.size.height = 20;
  53. frame.origin.y = frame.origin.y + 12;
  54. frame.origin.x += 4;
  55. [imgView setFrame:frame];
  56. //CGImageRelease(imageRefA);
  57. CGImageRelease(imageRef);
  58. [actionSheet addSubview: imgView];
  59. [imgView release];
  60.  
  61. }
  62. i++;
  63. }
  64. }
Add Comment
Please, Sign In to add comment