Giter VIP home page Giter VIP logo

custompopoverview's Introduction

A custom popoverView

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.

The preview chart is as follows

demo demo2

How to use

custom view


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, 60, 40);
view.content = btn;    
[view showFrom:sender alignStyle:CPAlignStyleRight];

custom viewController


	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];

normal use(only needs an array of titles)


	_titles = @[@"Menu1", @"Menu2", @"Ah_Menu3"];
	PopOverVieConfiguration *config = [PopOverVieConfiguration new];
    config.triAngelHeight = 5.0;
    config.triAngelWidth = 7.0;
    config.containerViewCornerRadius = 3.0;
    config.roundMargin = 2.0;
    config.defaultRowHeight = 30;
    config.tableBackgroundColor = [UIColor grayColor];
    config.textColor = [UIColor orangeColor];
	
	
	CustomPopOverView *view = [[CustomPopOverView alloc]initWithBounds:CGRectMake(0, 0, 200, 44*3) titleMenus:_titles config:config];
	view.containerBackgroudColor = [UIColor blueColor];
	view.delegate = self;
	[view showFrom:sender alignStyle:CPAlignStyleCenter];

if you have any question welcome to issue to me,hope you like it!


一款自定义 弹出视图

自定义弹出视图,内容支持传一组菜单标题,也支持自定义view,或者自定义viewController, 支持任意按钮触发,会显示在按钮底部,也支持切换按钮的对齐方式:左对齐、居中、右对齐

预览图如下

预览图 demo2

用法

自定义view


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, 60, 40);
view.content = btn;    
[view showFrom:sender alignStyle:CPAlignStyleRight];

自定义VC


	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];

普通用法(只传一组菜单名称)


	_titles = @[@"Menu1", @"Menu2", @"Ah_Menu3"];
	PopOverVieConfiguration *config = [PopOverVieConfiguration new];
    config.triAngelHeight = 5.0;
    config.triAngelWidth = 7.0;
    config.containerViewCornerRadius = 3.0;
    config.roundMargin = 2.0;
    config.defaultRowHeight = 30;
    config.tableBackgroundColor = [UIColor grayColor];
    config.textColor = [UIColor orangeColor];
	
	
	CustomPopOverView *view = [[CustomPopOverView alloc]initWithBounds:CGRectMake(0, 0, 200, 44*3) titleMenus:_titles config:config];
	view.containerBackgroudColor = [UIColor blueColor];
	view.delegate = self;
	[view showFrom:sender alignStyle:CPAlignStyleCenter];

如果你有问题欢迎issue,希望你能够喜欢

custompopoverview's People

Contributors

maltsugar avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.