美文网首页
iOS自定义AlertView

iOS自定义AlertView

作者: 丶墨墨丶 | 来源:发表于2019-03-22 13:10 被阅读0次

在iOS开发中,我们经常会用到一些提示框或者一些弹出菜单,但是这些视图系统自带的视图是满足不了的,比如这种:

WechatIMG186.jpeg
再比如这种: WechatIMG185.jpeg

这个时候就需要我们自定义AlertView:

下边CenterAlertContentView是自定义contentView

// 从中间弹出
- (IBAction)centerAlertAction:(id)sender {
    NKAlertView *alertView = [[NKAlertView alloc] init];
    CenterAlertContentView *customContentView = [[CenterAlertContentView alloc] initWithFrame:CGRectMake(0, 0, 281, 281)];
    alertView.contentView = customContentView;
    // 点击背景隐藏提示框
    alertView.hiddenWhenTapBG = YES;
    [alertView show];
}

从底部弹出时添加圆角:

/*
         利用贝塞尔曲线为contentView的左上角、右上角设置圆角;
         如果不需要可以注释下边代码
         */
        UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:_contentView.bounds byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(10, 10)];
        CAShapeLayer *shapeLayer = [CAShapeLayer layer];
        shapeLayer.frame = _contentView.bounds;
        shapeLayer.path = path.CGPath;
        _contentView.layer.mask = shapeLayer;

效果:


2019-03-21 12_47_59.gif

其他

GitHub地址

相关文章

  • 自定义AlertView

    自定义AlertView 之囧事 昨天被 AlertView、AlertController虐了 ...然鹅发现...

  • ios自定义AlertView

    先上图,弹框的背景色,按钮背景色,提示的消息的字体颜色都可以改变 利用单例实现丰富的自定义接口 .m文件中初始化控...

  • iOS自定义alertview

    在家闲来无事,于是就看起来ios绘图的那块,写点什么好呢? 鼓捣了一会,总算写出了一个小东西 这个是写完以后的效果...

  • iOS 自定义AlertView

    iOS 自带的UIAlertView 与UIAlertController功能非常局限,有时候需要我们自定义Ale...

  • iOS自定义AlertView

    ELAlertView ELAlertView 可以定制化弹框的外形和其内容,最关键的是可以放置图片. 你可以使...

  • iOS自定义AlertView

    在iOS开发中,我们经常会用到一些提示框或者一些弹出菜单,但是这些视图系统自带的视图是满足不了的,比如这种:Wec...

  • IOS 提示框UIAlertView,UIActionSheet

    一:UIAlertView警告框 IOS 2 - IOS 9 UIAlertView*AlertView=[[UI...

  • ios AlertView 自定义弹窗

    自定义弹窗,虽然同样的Dome很多,但我还是厚颜无耻的再共享一个自己写的吧!这个弹窗我定义了两种实现模式,一种是 ...

  • iOS 自定义AlertView(OC)

    最近项目中,要使用AlertView提示框,其实和UIAlertView类似的方式,只是按钮颜色发生修改。Aler...

  • iOS自定义控件-AlertView

    本控件项目地址,希望能给个start,欢迎大家交流指正。 简单说明 有简单动画效果,高度可根据内容自适应,点击事件...

网友评论

      本文标题:iOS自定义AlertView

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