SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. UIImageView *container = [[UIImageView alloc] initWithFrame:CGRectMake(0.0, 0.0f, 299.0f, 298.0f)];
  2.     container.image = [UIImage imageNamed:@"AR_RF004_circle.png"];
  3.     container.center = CGPointMake(self.view.bounds.size.width/2.0, self.view.bounds.size.height/2.0);
  4.     [self.view addSubview:container];
  5.  
  6.     NSArray *imagesArray = [[NSArray alloc]initWithObjects:[UIImage imageNamed:@"AR1.png"],[UIImage imageNamed:@"AR2.png"],[UIImage imageNamed:@"AR3.png"],[UIImage imageNamed:@"AR4.png"],[UIImage imageNamed:@"AR5.png"], nil];
  7. int numberOfSections = 5;
  8.     CGFloat angleSize = 2*M_PI/numberOfSections;
  9. for (int j = 0; j < numberOfSections; ++j) {
  10.         UIButton *sectionLabel = [[UIButton alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 150.0f, 128.0f)];
  11. [sectionLabel setBackgroundImage:[imagesArray objectAtIndex:j] forState:UIControlStateNormal];
  12. sectionLabel.layer.anchorPoint = CGPointMake(0.9f, 0.1f);
  13.         sectionLabel.layer.position = CGPointMake(container.bounds.size.width/2.0, container.bounds.size.height/2.0); // places anchorPoint of each label directly in the center of the circle.
  14.  
  15.         sectionLabel.transform = CGAffineTransformMakeRotation(angleSize*j);
  16.         [container addSubview:sectionLabel];
  17.     NSLog(@"section label x and y is %f ,%f",sectionLabel.frame.origin.x,sectionLabel.frame.origin.y);
  18.     }
  19.     [container release];
  20.    
  21. UIButton *currentButton;
  22. int buttonCount = 20;
  23. int radius = 200;
  24. float angleBetweenButtons = (2 * M_PI) / buttonCount;
  25. float x = 0;
  26. float y = 0;
  27. CGAffineTransform rotationTransform;
  28.  
  29. for (int i = 0; i < buttonCount; i++)
  30. {
  31.     // get your button from array or something
  32.     currentButton = ...
  33.     ...
  34.  
  35.     x = radius + cosf(i * angleBetweenButtons) * radius;
  36.     y = radius + sinf(i * angleBetweenButtons) * radius;
  37.     rotationTransform = CGAffineTransformIdentity;
  38.     rotationTransform = CGAffineTransformRotate(rotationTransform, (i * angleBetweenButtons));
  39.     currentButton.center = CGPointMake(x, y);
  40.     currentButton.transform = rotationTransform;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top