kResourceShowAll模式黑边问题如何用图片填充解决

kResourceShowAll模式黑边问题如何用图片填充解决  

 // Add the view controller's view to the window and display.
    window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
    CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [window bounds]
                                     pixelFormat: (NSString*)cocos2d::GLViewImpl::_pixelFormat
                                     depthFormat: cocos2d::GLViewImpl::_depthFormat
                              preserveBackbuffer: NO
                                      sharegroup: nil
                                   multiSampling: NO
                                 numberOfSamples: 0 ];


    [eaglView setMultipleTouchEnabled:YES];
    
    // Use RootViewController manage CCEAGLView
    viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];
    viewController.wantsFullScreenLayout = YES;
    viewController.view = eaglView;
    viewController.view.backgroundColor = [UIColor clearColor];
    
    
    UIViewController* uiVC = [[[UIViewController alloc] init]autorelease];
    videoView = [[UIView alloc] init];
    UIImageView *bgImageView= [[[UIImageView alloc]init]autorelease];
    
    UIImage *image = [UIImage imageNamed:@"res/images/bg.jpg"];
    [bgImageView setImage:image];
    
    CGFloat width = CGImageGetWidth(image.CGImage);
    CGFloat height = CGImageGetHeight(image.CGImage);
    
    CGSize _screenSize =  [[UIScreen mainScreen] currentMode].size;
    float _scaleX;
    float _scaleY;
    
    if (_screenSize.width > 0 && _screenSize.height > 0
        && width > 0 && height > 0)
    {
        _scaleX = (float)_screenSize.width / 480;
        _scaleY = (float)_screenSize.height / 800;
        _scaleX = _scaleY = MIN(_scaleX, _scaleY);
    }
    if (_scaleX <= 1)
    {
        [bgImageView setFrame:CGRectMake(0, 0, width/2, height/2)];
    }
    else
    {
        [bgImageView setFrame:CGRectMake(0, 0, width*_scaleX/2, height*_scaleX/2)];
    }
    
    CGSize _winSize = [[UIScreen mainScreen] bounds].size;
    [bgImageView setCenter:CGPointMake(_winSize.width/2, _winSize.height/2)];
    [uiVC.view addSubview:bgImageView];
    [uiVC.view addSubview:videoView];
    [uiVC.view addSubview:viewController.view];
    
    // Set RootViewController to window
    if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
    {
        // warning: addSubView doesn't work on iOS6
        [window addSubview: uiVC.view];
    }
    else
    {
        // use this method on ios6
        [window setRootViewController:uiVC];
    }
    
    [window makeKeyAndVisible];


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值