自定义弹出视图,内容支持传一组菜单标题,也支持自定义 view,或者自定义 viewController, 支持任意按钮触发,会显示在按钮底部,也支持切换按钮的对齐方式:左对齐、居中、右对齐
CustomPopOverView
拖进去pod 'CustomPopOverView'
CustomPopOverView *view = [CustomPopOverView popOverView];
view.content = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 100, 200)];
view.containerBackgroudColor = [UIColor blueColor];
[view showFrom:_leftBtn alignStyle:CPAlignStyleLeft];
CustomPopOverView *view = [CustomPopOverView popOverView];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeInfoDark];
btn.bounds = CGRectMake(0, 0, 160, 40);
view.content = btn;
[view showFrom:sender alignStyle:CPAlignStyleRight];
UIViewController *vc = [[UIViewController alloc]init];
vc.view.backgroundColor = [UIColor yellowColor];
vc.view.frame = CGRectMake(0, 0, 200, 200);
UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 140, 100)];
lab.center = vc.view.center;
lab.text = @"I'm viewController's view";
lab.numberOfLines = 0;
[vc.view addSubview:lab];
CustomPopOverView *view = [CustomPopOverView popOverView];
view.contentViewController = vc;
[view showFrom:_rightBtn alignStyle:CPAlignStyleRight];
NSArray *menus = @[@"清空已完成", @"清空全部"];
CPShowStyle *style = [CPShowStyle new];
style.roundMargin = 5;
style.triAngelHeight = 0.0;
style.triAngelWidth = 0.0;
style.containerCornerRadius = 5.0;
style.roundMargin = 10.0;
style.showSpace = 5.f;
style.containerBackgroudColor = RGBCOLOR(64, 64, 64);
style.containerBorderColor = UIColor.orangeColor;
style.containerBorderWidth = 2;
CustomPopOverView *pView = [[CustomPopOverView alloc]initWithBounds:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width - 40, 300) titleMenus:menus style:style];
pView.delegate = self;
[pView showFrom:nil alignStyle:CPAlignStyleRight];
This custom popover view, you can give an array of menu titles for normal use. It also support custom view or viewController. It’s frame depends on the button which clicked, and it provides three alignments for the button.
CustomPopOverView *view = [CustomPopOverView popOverView];
view.content = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 100, 200)];
view.containerBackgroudColor = [UIColor blueColor];
[view showFrom:_leftBtn alignStyle:CPAlignStyleLeft];
CustomPopOverView *view = [CustomPopOverView popOverView];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeInfoDark];
btn.bounds = CGRectMake(0, 0, 160, 40);
view.content = btn;
[view showFrom:sender alignStyle:CPAlignStyleRight];
UIViewController *vc = [[UIViewController alloc]init];
vc.view.backgroundColor = [UIColor yellowColor];
vc.view.frame = CGRectMake(0, 0, 200, 200);
UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 140, 100)];
lab.center = vc.view.center;
lab.text = @"I'm viewController's view";
lab.numberOfLines = 0;
[vc.view addSubview:lab];
CustomPopOverView *view = [CustomPopOverView popOverView];
view.contentViewController = vc;
[view showFrom:_rightBtn alignStyle:CPAlignStyleRight];
NSArray *menus = @[@"清空已完成", @"清空全部"];
CPShowStyle *style = [CPShowStyle new];
style.roundMargin = 5;
style.triAngelHeight = 0.0;
style.triAngelWidth = 0.0;
style.containerCornerRadius = 5.0;
style.roundMargin = 10.0;
style.showSpace = 5.f;
style.containerBackgroudColor = RGBCOLOR(64, 64, 64);
style.containerBorderColor = UIColor.orangeColor;
style.containerBorderWidth = 2;
CustomPopOverView *pView = [[CustomPopOverView alloc]initWithBounds:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width - 40, 300) titleMenus:menus style:style];
pView.delegate = self;
[pView showFrom:nil alignStyle:CPAlignStyleRight];