If the segments are equal, why not just divide the width of the control by the number of the selected segment (+1, because the numbering starts at 0)? EDIT: Like this one
-(void)showPopover:(id)sender { if ((UISegmentedControl*)sender.selectedSegmentIndex == 0) [self.popover presentPopoverFromRect:CGRectMake(self.segmentedControl.frame.size.width/6, self.segmentedControl.frame.origin.y, aWidth, aHeight)] }
This is more than 6 (I assume an implementation of 3 segments), because you need to get the center of the segment, and 3 - put it on the line. And if you do some simple math here (let's say that the entire control is 60 pixels wide), then 60/3 yeilds 20. Since each segment has a width of 20 pixels, a width of 60 by six gives the correct answer of 10.
source share