本文出处刚刚在线:http://www.superqq.com/blog/2015/10/30/two-nice-uialertview/
UIAlertView大家都不陌生了。UIAlertView不可以添加控件,比如说:UILabel、UITextView等等,所以遇到这个需求,一般都要自定义UIAlertView来解决。
我再github上找到了两个非常错的自定义UIAlertView第三方类库,分别是:LMAlertView和CustomIOSAlertView。
LMAlertView使用简介
LMAlertView在github上有610个star。说明这个第三方的UIAlertView还不错,我大概看了一下用法也比较简单。
来看看两个个案例效果:
用CocoaPods安装LMAlertView
pod 'LMAlertView'
使用案例
LMAlertView *alertView = [[LMAlertView alloc] initWithTitle:@"iOSDevTip"
message:@"关注一下"
delegate:nil
cancelButtonTitle:@"ok"
otherButtonTitles:nil];
// Add your subviews here to customise
UIView *contentView = alertView.contentView;
[alertView show];
LMAlertView还保持着UIAlertView的创建方法,作者还比较用心。
CustomIOSAlertView使用简介
CustomIOSAlertView比LMAlertView的star还多一些,有861个。同样我们先看一下效果:
用CocoaPods安装CustomIOSAlertView
pod 'CustomIOSAlertView', '~> 0.9.3'
使用案例
CustomIOSAlertView *alertView = [[CustomIOSAlertView alloc] init]; UIView *customView ..;
[alertView setContainerView:customView];
[alertView show];
CustomIOSAlertView可以设置代理,还可以通过block来实现按钮的点击事件。功能相对比较齐全。