UIAlertView大家都不陌生了。UIAlertView不可以添加控件,比如说:UILabel、UITextView等等,所以遇到这个需求,一般都要自定义UIAlertView来解决。
我再github上找到了两个非常错的自定义UIAlertView第三方类库,分别是:LMAlertView和CustomIOSAlertView。
LMAlertView ( https://github.com/lmcd/LMAlertView ) 在github上有610个star。说明这个第三方的UIAlertView还不错,我大概看了一下用法也比较简单。
来看看两个个案例效果:
pod 'LMAlertView'
LMAlertView *alertView = [[LMAlertView alloc] initWithTitle:@"iOSDevTip"message:@"关注一下"delegate:nilcancelButtonTitle:@"ok"otherButtonTitles:nil];// Add your subviews here to customiseUIView *contentView = alertView.contentView;[alertView show];
LMAlertView还保持着UIAlertView的创建方法,作者还比较用心。
CustomIOSAlertView ( https://github.com/wimagguc/ios-custom-alertview )比LMAlertView的star还多一些,有861个。同样我们先看一下效果:
pod 'CustomIOSAlertView', '~> 0.9.3'
CustomIOSAlertView *alertView = [[CustomIOSAlertView alloc] init]; UIView *customView ..;[alertView setContainerView:customView];[alertView show];
CustomIOSAlertView可以设置代理,还可以通过block来实现按钮的点击事件。功能相对比较齐全。
喜欢的童鞋可以star一下,以备不时之需。如果你觉得不错,记得分享给更多朋友哈,谢谢!
【今日微信公号推荐↓】
联系客服