JSPatch icon indicating copy to clipboard operation
JSPatch copied to clipboard

在js的中初始化的view,添加到界面中以后,获取center(),值依旧是他父视图的center

Open ShixinPeng opened this issue 8 years ago • 1 comments

var logHeight = 60; var logView = UIView.alloc().init(); logView.setCenter(self.view().center()); logView.setBounds({x:0, y:0, width:300, height:logHeight}); logView.setBackgroundColor(UIColor.grayColor()); self.view().addSubview(logView);

        //底部的背景
        var titleView = UIView.alloc().init();
        titleView.setBackgroundColor(UIColor.redColor());
        titleView.setFrame({x:logHeight*0.5, y:0, width:logView.bounds().width - logHeight*0.5, height:logHeight});
        logView.addSubview(titleView);
        //底部背景图片
        var backImageView = UIImageView.alloc().init();
        backImageView.setImage(UIImage.imageNamed("02"));
        logView.setNeedsLayout();
        var logviewCenter = logView.bounds().center();
        backImageView.setBounds(logView.bounds());
        
        ==》backImageView.setCenter(logviewCenter);《==
        titleView.addSubview(backImageView);

ShixinPeng avatar Nov 28 '16 11:11 ShixinPeng

啥意思没看懂

bang590 avatar Dec 01 '16 06:12 bang590