I want to move the UIPopoverArrowDirection
to the left such that the actual arrow is no longer centered but more 25% from the left and 75% from the right.
To help understand what I mean see the two screen shots I want it to be like the second one...
The problem is that there is no real way to dig down into the popover class...
This is already doable with the builtin class by specifing "presentPopoverFromRect" and making that rect constrained enough.
The below is code taken straight out of the code that results in the above. The extra fluff is because the little cogwheel thing is in a UIToolbar in a UINavigationBar. r
is the frame of the UIToolbar and it's being tweaked to hit the right spot (for the arrow) or it'd be slightly off-center. MGSettingsView
is the view controller (with "Enable transitions", "Enable night mode", etc in it).
UINavigationItem *item = scrollView.navbar.topItem;
UIToolbar *authorTools = (UIToolbar *)[item.rightBarButtonItem customView];
CGRect r = authorTools.frame;
r.size.width = 18;
r.origin.x += 12;
CGSize popoverSize = CGSizeMake(300.f, 500.f);
MGSettingsView *settingsView = [[MGSettingsView alloc] initWithSize:popoverSize];
UIPopoverController *poctl = [[UIPopoverController alloc] initWithContentViewController:settingsView];
settingsView.popover = poctl;
poctl.delegate = self;
poctl.popoverContentSize = popoverSize;
[poctl presentPopoverFromRect:r inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[settingsView release];
If this isn't what you're asking for you'd better rephrase your question I think. :)
The UIPopoverController class provides a simple way to display content from coordinates (Rect). You have the ability to set the popoverArrowDirection
you want to autorize, and that's it. From these informations, the system will automatically display the popover to fit in screen and respect the directin you want, you can not ask for more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With