美文网首页iOS学习专题
ios弹窗视图,使用block处理点击事件

ios弹窗视图,使用block处理点击事件

作者: HurryUpCheng | 来源:发表于2018-04-25 21:54 被阅读482次
    QQ20180425-213551-HD---.gif

    很简单的弹窗视图控件,可以设置箭头方向在视图的上下左右,可以自定义视图背景颜色,判断视图超出屏幕自动改变位置

    使用很简单,默认白色背景箭头在上面
    
    - (IBAction)leftTop:(UIButton *)sender {
        
        CGPoint point = CGPointMake(sender.czh_centerX, sender.czh_centerY + CZH_ScaleWidth(20));
        
        CZHPopUpView *view = [CZHPopUpView czh_popUpWithPoint:point arrowOffset:CZH_ScaleWidth(150)];
        
        [view czh_addItemWithImageName:@"" title:@"点击左上" clickHandler:^(CZHPopUpItem *item) {
            NSLog(@"点击左上");
        }];
        
        [view czh_addItemWithImageName:@"person_data_add_black" title:@"拉黑" clickHandler:^(CZHPopUpItem *item) {
            NSLog(@"点击拉黑");
        }];
        
        
        [view czh_addItemWithImageName:@"person_data_report" title:@"投诉" clickHandler:^(CZHPopUpItem *item) {
            NSLog(@"点击投诉");
        }];
        
        [view czh_showView];
    }
    
    
    自定义颜色和箭头方向
    - (IBAction)left:(UIButton *)sender {
        
        CGPoint point = CGPointMake(sender.czh_centerX - CZH_ScaleWidth(20), sender.czh_centerY);
        
        CZHPopUpView *view = [CZHPopUpView czh_popUpWithPoint:point arrowOffset:CZH_ScaleWidth(0) directionType:CZHPopUpViewDirectionTypeRight];
        
        [view czh_addItemWithImageName:@"" title:@"点击左上" clickHandler:^(CZHPopUpItem *item) {
            NSLog(@"点击左上");
        }];
        
        [view czh_addItemWithImageName:@"person_data_add_black" title:@"拉黑" clickHandler:^(CZHPopUpItem *item) {
            NSLog(@"点击拉黑");
        }];
        [view czh_addItemWithImageName:@"person_data_report" title:@"投诉" clickHandler:^(CZHPopUpItem *item) {
            NSLog(@"点击投诉");
        }];
        [view czh_addItemWithImageName:@"person_data_report" title:@"投诉" clickHandler:^(CZHPopUpItem *item) {
            NSLog(@"点击投诉");
        }];
        [view czh_addItemWithImageName:@"person_data_report" title:@"投诉" clickHandler:^(CZHPopUpItem *item) {
            NSLog(@"点击投诉");
        }];
        [view czh_addItemWithImageName:@"person_data_report" title:@"投诉" clickHandler:^(CZHPopUpItem *item) {
            NSLog(@"点击投诉");
        }];
        [view czh_addItemWithImageName:@"person_data_report" title:@"投诉" clickHandler:^(CZHPopUpItem *item) {
            NSLog(@"点击投诉");
        }];
        [view czh_showView];
    }
    
    

    查看博客
    查看github

    公司的项目.png

        公司的项目,求支持,如果发现什么问题,可以留言反应,感激不尽    

    相关文章

      网友评论

      本文标题:ios弹窗视图,使用block处理点击事件

      本文链接:https://www.haomeiwen.com/subject/cvkulftx.html