Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is more of a math question than a code question, but I'll take a stab.</p> <p>Assuming you want the first item at the top, and then placing items clockwise around the main image, you are going to be altering one variable as you go through the for loop: the angle.</p> <p>You then calculate the x and y coordinates in each iteration by converting your angle and radius(which is likely constant) to cartesian coordinates, and adding the result to the coordinates of the center of the image. This needs to be done within the for loop, not at the beginning as you have it in your code.</p> <p>The amount you will add to the angle on each iteration of the loop is <code>2*M_PI / arrayCount</code>.</p> <p>This is roughly what I'm thinking:</p> <pre><code>- (void)loadContent{ NSString *filename6 = [[NSUserDefaults standardUserDefaults]objectForKey:@"Setting"]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *groupPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", filename6]]; NSString *fileContent = [[NSString alloc] initWithContentsOfFile:groupPath]; NSMutableArray* array = [[NSMutableArray alloc] initWithArray:[fileContent componentsSeparatedByString:@", "]]; int arrayCount = array.count; CGFloat radius = 300;// &lt;--- INSERT RADIUS HERE CGFloat angle = 0;// &lt;--- The starting angle CGPoint center = CGPointMake(300,300); // &lt;--- INSERT CENTER OF ARRANGEMENT for(int i = 0; i &lt; [array count]; i++){ int yCoordinate = radius * cos(angle) + center.y; int xCoordinate = radius * sin(angle) + center.x; CGRect textframe = CGRectMake( the xcoordinate, the ycoordinate, 328, 30); NSString *nameOfGroup = [array objectAtIndex:i]; UITextView* theGroupTextLabel; theGroupTextLabel = [[UITextView alloc] initWithFrame: textframe]; [theGroupTextLabel setText: nameOfGroup]; [theGroupTextLabel setTextColor: [UIColor redColor]]; [self.view addSubview:theGroupTextLabel]; //theGroupTextLabel.enabled = NO; theGroupTextLabel.backgroundColor = [UIColor clearColor]; theGroupTextLabel.layer.borderWidth = 3.5f; theGroupTextLabel.layer.borderColor = [[UIColor blackColor] CGColor]; int z; z = z + 1; theGroupTextLabel.tag = z; // INCREMENT ANGLE angle += 2 * M_PI / array.count; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload