当前位置: 代码迷 >> Iphone >> 奇怪的有关问题,VIEW移除不掉!
  详细解决方案

奇怪的有关问题,VIEW移除不掉!

热度:77   发布时间:2016-04-25 06:14:26.0
奇怪的问题,VIEW移除不掉!!!!!!!!!
在网上下了一个弹出一个窗口的例子,如下
#import "UIDialogWindow.h"

@implementation UIDialogWindow

@synthesize view;
@synthesize superView;
@synthesize backgroundView;
@synthesize backgroundImage;


-(UIDialogWindow *)initWithView:(UIView *)aView:(NSInteger)degree
{
    if (self=[super init]) {
        //内容view
        self.view=aView;
     //   NSLog(@"initWithView");
        [self setFrame:[[UIScreen mainScreen]bounds]];
        self.windowLevel=UIWindowLevelStatusBar;
        self.backgroundColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];
        
        //根view
        UIView *sv=[[UIView alloc] initWithFrame:[self bounds]];
        self.superView=sv;
        [superView setAlpha:0.0f];
        [self addSubview:superView];
        [sv release];
        
        CGFloat d=-7.0f;
        UIView *bv=[[UIView alloc] initWithFrame:CGRectInset(CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height),d,d)];
        self.backgroundView=bv;
        
        //圆角图片背景view
        UIImageView *bi=[[UIImageView alloc] initWithImage:[[Global pngWithPath:@"ipad_casino_limit"]stretchableImageWithLeftCapWidth:0.8 topCapHeight:0.5]];
        self.backgroundImage=bi;
        [backgroundImage setFrame:[backgroundView bounds]];
        [backgroundView insertSubview:backgroundImage atIndex:0];
        [backgroundView setCenter:CGPointMake(superView.bounds.size.width/2, superView.bounds.size.height/2)];
        backgroundView.transform = CGAffineTransformIdentity;
        backgroundView.transform = CGAffineTransformMakeRotation(degreesToRadians(degree));
        [superView addSubview:backgroundView];
        
        CGRect frame=CGRectInset([backgroundView bounds], -1*d, -1*d);
        //显示内容view
        [self.view setCenter:CGPointMake(superView.bounds.size.width/2, superView.bounds.size.height/2)];
        [backgroundView addSubview:self.view];
        [self.view setFrame:frame];
        isClose=NO;
        [bv release];
        [bi release];
    }
    
  相关解决方案