// 对外暴露两个方法供调用
+ (void)showToast:(NSString *)text;
+ (void)showToast:(NSString *)text inView:(UIView *)superView;
// 实现方法
+ (void)showToast:(NSString *)text{
[ToastUtil showToast:text inView:[UIApplication sharedApplication].windows.lastObject];
}
+ (void)showToast:(NSString *)text inView:(UIView *)superView {
if (!superView) {
return;
}
CGSize labelSize = [text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:20.f]}];
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont systemFontOfSize:18.f];
label.text = text;
label.textAlignment = NSTextAlignmentCenter;
label.layer.cornerRadius = labelSize.height/4;
label.layer.masksToBounds = YES;
label.backgroundColor = [UIColor colorWithRed:38/255.f green:187/255.f blue:251/255.f alpha:1.f];
label.textColor = [UIColor whiteColor];
label.frame = CGRectMake((superVie