在 UIVIew/UIWindow 上显示自定义 AlertView
很简单。只需在桌面下载或克隆。将源代码文件夹和资源文件夹拖放到您的项目中。之后,在任何您希望添加的位置添加以下语句。
#import <SAMAlertView.h> /*If you added via cocoapods*/
#import "SAMAlertView.h" /*If you added manually*/
SAMAlertView *alertView = [SAMAlertView alertWithTitle:@"Your Custom Alert Title" message:@"Your custom message will appear here!"];
[alertView setButtonTitles:@[@"CANCEL",@"ADD"]];
[alertView setButtonColors:@[COLOR_RGBA(232, 234, 234, 1), COLOR_RGBA(65, 150, 241, 1)]];
[alertView setButtonTitleColors:@[COLOR_RGBA(145, 145, 145, 1), COLOR_RGBA(255, 255, 255, 1)]];
[alertView setButtonImages:@[IMAGE_CROSS_ICON,IMAGE_ADD_ICON]];
[alertView setCustomButtonAlignment:CustomButtonAlignmentHorizontal];
//[alertView setCustomButtonAlignment:CustomButtonAlignmentVertical];
[alertView setOnButtonTouchUpInside:^(SAMAlertView *alertView, int buttonIndex) {
NSLog(@"Block: Button at position %d is clicked on alertView %ld.", buttonIndex, (long)[alertView tag]);
}];
[alertView show];
水平按钮
垂直按钮
请随时为该项目做出贡献。计划添加更多方法。
关注我:
Twitter (@milan_panchal24)
Github (/milanpanchal)
SAMCustomAlertView 根据 MIT 许可证提供。有关更多信息,请参阅许可证文件。