#import <UIKit/UIKit.h>
@interface UIView (Extension_1)
+ (UIView *)viewWithFrame:(CGRect)frame
backgroundColor:(UIColor *)backgroundColor;
- (UIViewController *)viewController;
//毛玻璃
+ (UIVisualEffectView *)effectViewWithFrame:(CGRect)frame;
@end
#import "UIView+Extension_1.h"
@implementation UIView (Extension_1)
+ (UIView *)viewWithFrame:(CGRect)frame
backgroundColor:(UIColor *)backgroundColor
{
UIView *view =[[UIView alloc]initWithFrame:frame];
view.backgroundColor =backgroundColor;
return view;
}
- (UIViewController *)viewController{
UIResponder *next = self.nextResponder;
do {
if ([next isKindOfClass:[UIViewController class]]) {
return (UIViewController *)next;
}
next = next.nextResponder;
} while (next != nil);
return nil;
}
+ (UIVisualEffectView *)effectViewWithFrame:(CGRect)frame
{
UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *effectView = [[UIVisualEffectView alloc] initWithEffect:effect];
effectView.frame = frame;
return effectView;
}
@end
网友评论