Skip to content

Latest commit

 

History

History
81 lines (64 loc) · 2.08 KB

README.md

File metadata and controls

81 lines (64 loc) · 2.08 KB

XLPopup

Customizable popup for iOS.

XLPopup is now available.

Preview

img

Usage

Custom view from XLPopupView

Override init Method

CustomPopupView.m

+ (instancetype)showPopupViewWithShowType:(XLPopupShowType)showType maskType:(XLPopupMaskType)maskType
{
    CustomPopupView *popupView = [[CustomPopupView alloc] initWithSuperView:nil showType:showType maskType:maskType];
    [popupView show];
    return popupView;
}

#pragma mark - Override Method

- (instancetype)initWithSuperView:(UIView *)superView showType:(XLPopupShowType)showType maskType:(XLPopupMaskType)maskType
{
    self = [super initWithSuperView:superView showType:showType maskType:maskType];
    if (self) {
        self.delegate = self;
	//----------custom setup subviews----------
        BOOL isMaskLight;
        if (maskType == XLPopupMaskTypeNormal || maskType == XLPopupMaskTypeDarkBlur) {
            isMaskLight = NO;
        }else {
            isMaskLight = YES;
        }
        self.backgroundColor = isMaskLight? [UIColor grayColor]:[UIColor whiteColor];
        self.clipsToBounds = YES;
        self.layer.cornerRadius = 10;
        
        UILabel *label = [UILabel new];
        label.text = @"customView";
        label.textColor = isMaskLight? [UIColor whiteColor]:[UIColor grayColor];
        label.textAlignment = NSTextAlignmentCenter;
        [self addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
            make.width.equalTo(self);
        }];
       	//------------------------------------------
    }
    return self;
}

Implementation protocol

#pragma mark - XLPopupViewDelegate

- (void)popupViewLayoutFinalPostion
{
    [self mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.superview);
        make.height.equalTo(@(200));
        make.width.equalTo(self.superview).multipliedBy(0.8);
    }];
}

- (BOOL)popupViewDismissWhenMaskViewDidTap
{
    return YES;
}

TODO

Custom Animation Example