iOS自定义AlertView

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一下~
下班, 回家!

你可能感兴趣的:(iOS自定义AlertView)