QPopover

introduce

QPopover, iOS rounded shadow bubble control, support rounded shadow, arrow only support up and down direction, just provide an arrow up arrow picture

Effect of the sample

Install the tutorial

  1. Download the QPopover project source code from gitee: gitee.com/fireice2048…
  2. Copy qpopOverViewController.h/qPopOverViewController.m to the target project
  3. Add the [email protected] image from the QPopover project to the target project
  4. Then follow the instructions below to write the code

Directions for use

#import "QPopoverViewController.h" - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. UIButton * button = [[UIButton alloc] initWithFrame:CGRectMake(40, 180, 100, 30)]; button.backgroundColor = [UIColor greenColor]; [button addTarget:self action:@selector(buttonClick:) forControlEvents:(UIControlEventTouchUpInside)]; [self.view addSubview:button]; } - (void)buttonClick:(UIView *)sender {// create a custom ContentView, place your own business UI element, set the width and height correctly (note the shadow size, default left and right is 30 pixels), UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 120)]; view.backgroundColor = [UIColor orangeColor]; QPopoverViewController * popover = [[QPopoverViewController alloc] init]; popover.userContentView = view; popover.anchorView = sender; UIImage * image = [UIImage imageNamed:@"popover_arrow_icon"]; UIImage * image = [UIImage imageNamed:@"popover_arrow_icon"]; popover.arrowImage = image; / / set the Angle arrow images [self presentViewController: popover animated: YES completion: nil]; }Copy the code
  1. You can modify the shadow parameters:
popover.borderContentView.layer.cornerRadius = 8; Popover. BorderContentView. Layer. ShadowColor = [[UIColor blackColor] colorWithAlphaComponent: 0.5]. CGColor; popover.borderContentView.layer.shadowOffset = CGSizeMake(0, 3); Popover. BorderContentView. Layer. ShadowOpacity = 0.8; / / shadow transparency, the default 0 popover. BorderContentView. Layer. ShadowRadius = 20;Copy the code
  1. You can also change the background color of the rounded border view
Popover. BorderContentView. BackgroundColor = [[UIColor greenColor] colorWithAlphaComponent: 0.4];Copy the code

When changing the rounded border background color, replace the pointed arrow image with the appropriate one

    popover.arrowImage = [UIImage imageNamed:@"xxx"];;
Copy the code
  1. You can change the size of the Border around the rounded Border
popover.borderEdgeInsets = UIEdgeInsetsMake(16, 16, 16, 16);
Copy the code