你好,我自定义了一个290*280的 View ,就像一个对话框,一切都可以,但是我的自定义 View 后面的其他 View 可以单击,我希望当我的自定义 View 弹出时其他 View 可以单击,我也想要窗口我的自定义 View 后面的内容是模糊的。
我的代码是:
#import <UIKit/UIKit.h>
@interface RecordView :UIView
@property (strong, nonatomic) IBOutlet UIButton *confirmBu;
@property (strong, nonatomic) IBOutlet UIButton *playBu;
@property (strong, nonatomic) IBOutlet UIButton *recrodBu;
@property (strong, nonatomic) IBOutlet UIButton *closeBu;
@property (strong, nonatomic) IBOutlet UIImageView *backgroundImageview;
@property (strong, nonatomic) IBOutlet UIImageView *showImageview;
-(void)setViewStyle;
@end
#import "RecordView.h"
@interface RecordView ()
@end
@implementation RecordView
@synthesize confirmBu;
@synthesize playBu;
@synthesize recrodBu;
@synthesize closeBu;
@synthesize backgroundImageview;
@synthesize showImageview;
-(void)setViewStyle{
self.frame=CGRectMake(15,100, 290, 280);
self.backgroundColor=[UIColor clearColor];
backgroundImageview.layer.masksToBounds=YES;
backgroundImageview.layer.cornerRadius=15.0;
backgroundImageview.layer.borderWidth=4.0;
backgroundImageview.layer.borderColor=[[UIColor lightGrayColor] CGColor];
}
@end
self.recordDialog= [[[NSBundle mainBundle] loadNibNamed:@"RecordView" owner:self options:nil]lastObject];
[self.recordDialog setViewStyle];
[delegate.window addSubview:self.recordDialog];
最佳答案
另一种方法是以编程方式创建当前屏幕的屏幕截图。使用类似 https://github.com/tomsoft1/StackBluriOS 来模糊屏幕截图然后将该图像设置为背景。当您单击关闭按钮时,您所要做的就是再次隐藏背景图像。
关于iphone - 将自定义 View 添加到窗口并模糊背景 View ,并且不允许单击背景 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14578851/