iOS自定义AlertView

作者: 小失 | 来源:发表于2016-05-29 18:31 被阅读391次

ELAlertView

ELAlertView 可以定制化弹框的外形和其内容,最关键的是可以放置图片. 你可以使用它来代替系统的UIAlertController/UIAlertView.
支持iOS7.

This project is inspired by NYAlertViewController

Gif图还是去github上看吧https://github.com/rainer-liao/ELAlertView .

Installation 安装

Manual 手动

下载本项目,将项目中的ELAlertView文件拖到你的Xcode工程就OK了.

CocoaPods

pod 'ELAlertView', '~>1.0.0'

How To Use 使用方法

// Import the class
#import "ELAlertView.h"

// ...
    // Create an instance
    ELAlertView *alertView = [[ELAlertView alloc] initWithStyle:ELAlertViewStyleDefault];
    
    // Set title and message if needed
    alertView.title   = @"title";
    alertView.message = @"message";
    
    // Custom your appearance
    alertView.titleTopMargin = 17;
    alertView.messageLeadingAndTrailingPadding = 20;
    alertView.messageAlignment = NSTextAlignmentLeft;
    alertView.messageHeight = 270;
    alertView.alertViewBackgroundColor = [UIColor redColor];
    alertView.titleColor = [UIColor blueColor];
    alertView.messageColor =[UIColor purpleColor];
    alertView.buttonBottomMargin = 30;
    
    // Add alert actions
    ELAlertAction *action = [ELAlertAction actionWithTitle:NSLocalizedString(@"ok", nil)
                                                     style:ELAlertActionStyleDestructive
                                                   handler:^(ELAlertAction *action) {
                                                       
                                                   }];
    [alertView addAction:action];
    
    // Show the alertView
    [alertView show];

License

This project is released under the MIT License.

一些碎语

约束是用系统自带的那套写的,非常恶心,还用了VTL. 想了解的同学可以去看看这篇文章http://xuexuefeng.com/autolayout/.
如果想要更多的定制化, 应该还是还有些事情可以做的. 一般情况下, 目前够用了.

如果有哪些不对的地方, 请多多指教.
如果觉得对你有帮助, 求帮star一下~
下班, 回家!

相关文章

  • 自定义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/pfeqdttx.html