#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
最后編輯于 :
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者