Reputation: 80
I am developing a chat application similar to WhatsApp. When the user long presses a message a popover with options is presented. I want to dim everything in the background except for the popover and the sourceView of the popover. Like this:
I tried this but all of the background gets dimmed:
- (void)prepareForPopoverPresentation:(UIPopoverPresentationController *)popoverPresentationController {
[[popoverPresentationController containerView] setBackgroundColor:[UIColor colorWithWhite:0 alpha:.72]];
}
Upvotes: 1
Views: 471
Reputation: 80
I managed to do it by recreating a cell and adding it to the popover containerView:
- (void)prepareForPopoverPresentation:(UIPopoverPresentationController *)popoverPresentationController {
[[popoverPresentationController containerView] setBackgroundColor:[UIColor colorWithWhite:0 alpha:.72]];
MessageCellNode *messageNode = [[MessageCellNode alloc] init];
UICollectionViewLayoutAttributes *attributes = [[self.collectionNode view] layoutAttributesForItemAtIndexPath:indexPathToSelect];
CGRect cellRect = attributes.frame;
CGRect rect = [[[self collectionNode] view] convertRect:cellRect toView:[[UIApplication sharedApplication] keyWindow]];
[messageNode setFrame: rect];
[[popoverPresentationController containerView]addSubview:[messageNode view]];
}
Upvotes: 1
Reputation: 93
Javad
You can add blank in full screen in the presenting view. Set black background color and alpha 0.5 which will create dim effect.
Thank you
Upvotes: 1